[GitHub] commons-lang pull request #357: Proposal for LANG-1421

2018-09-21 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/357#discussion_r219537218
  
--- Diff: src/main/java/org/apache/commons/lang3/ObjectUtils.java ---
@@ -236,6 +236,39 @@ public static boolean anyNotNull(final Object... 
values) {
 return firstNonNull(values) != null;
 }
 
+/**
+ * Checks if any value in the given array is {@code null}.
+ *
+ * 
+ * If none of the values are {@code null} or the array is {@code null}
+ * or empty then {@code false} is returned. Otherwise {@code true} is 
returned.
+ * 
+ *
+ * 
+ * ObjectUtils.anyNull(*)   = false
+ * ObjectUtils.anyNull(*, null) = true
+ * ObjectUtils.anyNull(null, *) = true
+ * ObjectUtils.anyNull(null, null, *, *)= true
+ * ObjectUtils.anyNull(null)= true
+ * ObjectUtils.anyNull(null, null)  = true
+ * ObjectUtils.anyNull()= false
+ * ObjectUtils.anyNull((Object[]) null) = false
+ * 
+ *
+ * @param values  the values to test, may be {@code null} or empty
+ * @return {@code true} if there is at least one null value in the 
array,
+ * {@code false} if all values in the array are not {@code null}s.
+ * If the array is {@code null} or empty {@code fatolse} is also 
returned.
--- End diff --

depending on how you feel, you could replace the `if the array is {@code 
null}` info with something about this method being null safe (to keep the 
wordage the same as other methods that use `null safe`)


---


[GitHub] commons-lang pull request #357: Proposal for LANG-1421

2018-09-21 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/357#discussion_r219536392
  
--- Diff: src/main/java/org/apache/commons/lang3/ObjectUtils.java ---
@@ -236,6 +236,39 @@ public static boolean anyNotNull(final Object... 
values) {
 return firstNonNull(values) != null;
 }
 
+/**
+ * Checks if any value in the given array is {@code null}.
+ *
+ * 
+ * If none of the values are {@code null} or the array is {@code null}
+ * or empty then {@code false} is returned. Otherwise {@code true} is 
returned.
+ * 
+ *
+ * 
+ * ObjectUtils.anyNull(*)   = false
+ * ObjectUtils.anyNull(*, null) = true
+ * ObjectUtils.anyNull(null, *) = true
+ * ObjectUtils.anyNull(null, null, *, *)= true
+ * ObjectUtils.anyNull(null)= true
+ * ObjectUtils.anyNull(null, null)  = true
+ * ObjectUtils.anyNull()= false
+ * ObjectUtils.anyNull((Object[]) null) = false
+ * 
+ *
+ * @param values  the values to test, may be {@code null} or empty
+ * @return {@code true} if there is at least one null value in the 
array,
+ * {@code false} if all values in the array are not {@code null}s.
+ * If the array is {@code null} or empty {@code fatolse} is also 
returned.
--- End diff --

`fatolse` -> `false` !


---


[GitHub] commons-lang pull request #269: LANG-1337: Fix test failures in IBM JDK 8 fo...

2017-06-06 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/269#discussion_r120386094
  
--- Diff: 
src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java ---
@@ -316,7 +316,7 @@ public void testReflectionHierarchyArrayList() {
 // representation different for IBM JDK 1.6.0, LANG-727
 assumeFalse("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && 
"1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION));
 assumeFalse("Oracle Corporation".equals(SystemUtils.JAVA_VENDOR) 
&& "1.6".compareTo(SystemUtils.JAVA_SPECIFICATION_VERSION) < 0);
-final List list = new ArrayList<>();
+final List list = new ArrayList<>(10);
--- End diff --

probably related to [this](https://stackoverflow.com/a/34250231)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang issue #269: LANG-1337: Fix test failures in IBM JDK 8 for ToStr...

2017-06-06 Thread andyklimczak
Github user andyklimczak commented on the issue:

https://github.com/apache/commons-lang/pull/269
  
probably related to [this](https://stackoverflow.com/a/34250231)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang issue #223: [LANG-1304] StringUtils method to check for mixed c...

2017-05-23 Thread andyklimczak
Github user andyklimczak commented on the issue:

https://github.com/apache/commons-lang/pull/223
  
hello friends, I've updated `isMixedCase()` to be much more accepting of 
special characters, numbers, and spaces. Please double check that my tests 
assert the strings correctly, and match the desired logic 

Let me know if anything seems wrong ! 🐤 🔥 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #223: [LANG-1304] StringUtils method to check for ...

2017-05-22 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/223#discussion_r117889175
  
--- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
@@ -7193,6 +7193,45 @@ public static boolean isAllUpperCase(final 
CharSequence cs) {
 return true;
 }
 
+/**
+ * Checks if the CharSequence contains mixed casing of both 
uppercase and lowercase characters.
+ *
+ * {@code null} will return {@code false}.
+ * An empty String (length()=0) will return {@code false}.
+ *
+ * 
+ * StringUtils.isMixedCase(null)= false
+ * StringUtils.isMixedCase("")  = false
+ * StringUtils.isMixedCase("aBc")   = true
+ * StringUtils.isMixedCase("ABC")   = false
+ * StringUtils.isMixedCase("abc")   = false
+ * StringUtils.isMixedCase("A c")   = false
+ * StringUtils.isMixedCase("A1c")   = false
+ * StringUtils.isMixedCase("a/C")   = false
+ * 
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {@code true} if contains both uppercase and lowercase 
characters, and is non-null
+ */
+public static boolean isMixedCase(final CharSequence cs) {
+if (cs == null || isEmpty(cs)) {
+return false;
+}
+boolean containsUppercase = false;
+boolean containsLowercase = false;
+final int sz = cs.length();
+for (int i = 0; i < sz; i++) {
--- End diff --

I missed this message before, will correct the logic sometime this week


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #228: Increase test coverage

2017-01-21 Thread andyklimczak
GitHub user andyklimczak opened a pull request:

https://github.com/apache/commons-lang/pull/228

Increase test coverage

CharRangeTest 98% -> 100%
RandomUtilsTest 90% -> 100%
StringEscapeUtilsTest 95% -> 100%
StringUtilsTest -> 99% (a few more lines covered)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/andyklimczak/commons-lang test-coverage

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/228.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #228


commit 00bf35cdd92813881274a355a33e7e659f5eddaa
Author: Andy Klimczak <andyklimc...@fastmail.com>
Date:   2017-01-21T07:50:50Z

Increase test coverage

CharRangeTest -> 100%
RandomUtilsTest -> 100%
StringEscapeUtilsTest -> 100%
StringUtils -> 99%




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #223: [LANG-1304] StringUtils method to check for ...

2016-12-29 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/223#discussion_r94203294
  
--- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
@@ -7193,6 +7193,45 @@ public static boolean isAllUpperCase(final 
CharSequence cs) {
 return true;
 }
 
+/**
+ * Checks if the CharSequence contains mixed casing of both 
uppercase and lowercase characters.
+ *
+ * {@code null} will return {@code false}.
+ * An empty String (length()=0) will return {@code false}.
+ *
+ * 
+ * StringUtils.isMixedCase(null)= false
+ * StringUtils.isMixedCase("")  = false
+ * StringUtils.isMixedCase("aBc")   = true
+ * StringUtils.isMixedCase("ABC")   = false
+ * StringUtils.isMixedCase("abc")   = false
+ * StringUtils.isMixedCase("A c")   = false
+ * StringUtils.isMixedCase("A1c")   = false
+ * StringUtils.isMixedCase("a/C")   = false
+ * 
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {@code true} if contains both uppercase and lowercase 
characters, and is non-null
+ */
+public static boolean isMixedCase(final CharSequence cs) {
+if (cs == null || isEmpty(cs)) {
+return false;
+}
+boolean containsUppercase = false;
+boolean containsLowercase = false;
+final int sz = cs.length();
+for (int i = 0; i < sz; i++) {
--- End diff --

This method seems like a hybrid/sister method to ```isAllUppercase()``` and 
```isAllLowercase()``` and treats non-alpha characters similarly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #223: [LANG-1304] StringUtils method to check for ...

2016-12-29 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/223#discussion_r94201194
  
--- Diff: src/test/java/org/apache/commons/lang3/StringUtilsTest.java ---
@@ -2563,6 +2563,24 @@ public void testIsAllUpperCase() {
 assertFalse(StringUtils.isAllUpperCase("A/C"));
 }
 
+/**
+ * Test for {@link StringUtils#isMixedCase(CharSequence)}.
+ */
+@Test
+public void testIsMixedCase() {
+assertFalse(StringUtils.isMixedCase(null));
+assertFalse(StringUtils.isMixedCase(StringUtils.EMPTY));
+assertFalse(StringUtils.isMixedCase(" "));
+assertTrue(StringUtils.isMixedCase("aBc"));
+assertFalse(StringUtils.isMixedCase("abc"));
+assertFalse(StringUtils.isMixedCase("ABC"));
+assertFalse(StringUtils.isMixedCase("aBc "));
+assertFalse(StringUtils.isMixedCase("A c"));
+assertFalse(StringUtils.isMixedCase("aBc\n"));
+assertFalse(StringUtils.isMixedCase("A1c"));
+assertFalse(StringUtils.isMixedCase("a/C"));
--- End diff --

Done, and I added a quick return case to skip going into the loop 
unnecessarily because a char sequence of length 1 cannot have both an upper and 
lowercase. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #223: [LANG-1304] StringUtils method to check for ...

2016-12-29 Thread andyklimczak
Github user andyklimczak commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/223#discussion_r94200421
  
--- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
@@ -7193,6 +7193,45 @@ public static boolean isAllUpperCase(final 
CharSequence cs) {
 return true;
 }
 
+/**
+ * Checks if the CharSequence contains mixed casing of both 
uppercase and lowercase characters.
+ *
+ * {@code null} will return {@code false}.
+ * An empty String (length()=0) will return {@code false}.
+ *
+ * 
+ * StringUtils.isMixedCase(null)= false
+ * StringUtils.isMixedCase("")  = false
+ * StringUtils.isMixedCase("aBc")   = true
+ * StringUtils.isMixedCase("ABC")   = false
+ * StringUtils.isMixedCase("abc")   = false
+ * StringUtils.isMixedCase("A c")   = false
+ * StringUtils.isMixedCase("A1c")   = false
+ * StringUtils.isMixedCase("a/C")   = false
+ * 
+ *
+ * @param cs the CharSequence to check, may be null
+ * @return {@code true} if contains both uppercase and lowercase 
characters, and is non-null
+ */
+public static boolean isMixedCase(final CharSequence cs) {
+if (cs == null || isEmpty(cs)) {
+return false;
+}
+boolean containsUppercase = false;
+boolean containsLowercase = false;
+final int sz = cs.length();
+for (int i = 0; i < sz; i++) {
--- End diff --

Almost, because consider the string "aB\n":
It does contain a lowercase, then an uppercase, but it also contains the 
character '\n', which is a neither lower or uppercase. Breaking early would 
miss this case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #223: [LANG-1304] StringUtils method to check for ...

2016-12-29 Thread andyklimczak
GitHub user andyklimczak opened a pull request:

https://github.com/apache/commons-lang/pull/223

[LANG-1304] StringUtils method to check for mixed case in string

[jira link](https://issues.apache.org/jira/browse/LANG-1304)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/andyklimczak/commons-lang LANG-1304

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/223.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #223


commit da8d4c6d93941c8b8ac62a4669fe4d57bbf6
Author: Andy Klimczak <andyklimc...@fastmail.com>
Date:   2016-12-30T02:01:12Z

[LANG-1304] StringUtils method to check for mixed case in string




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #200: LANG-1276

2016-10-22 Thread andyklimczak
GitHub user andyklimczak opened a pull request:

https://github.com/apache/commons-lang/pull/200

LANG-1276

Fix issue of buf using nonupdated buffer in StrBuilder replaceImpl
Avoid array OoB error by keeping variable buf consistent with buffer

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/andyklimczak/commons-lang LANG-1276

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/200.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #200


commit 0dd44493d70188ed6145cdb130537532cbc68522
Author: Andy Klimczak <andyklimc...@fastmail.com>
Date:   2016-10-23T01:54:14Z

LANG-1276
Avoid array OOB error by keeping variable buf consistent with buffer in
StrBuilder replaceImpl




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---