You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/08/20 22:24:22 UTC
(commons-lang) 06/07: Sort members
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit d5758118b5e245e052fa2378ceb76e049813d324
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Aug 20 18:20:45 2025 -0400
Sort members
---
.../java/org/apache/commons/lang3/StringUtils.java | 96 +++++++++++-----------
.../apache/commons/lang3/reflect/MethodUtils.java | 48 +++++------
2 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 6c43ea3b4..116d9e16d 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -2708,54 +2708,6 @@ public static int indexOfAny(final CharSequence cs, final char... searchChars) {
return indexOfAny(cs, 0, searchChars);
}
- /**
- * Search a CharSequence to find the first index of any character in the given set of characters.
- *
- * <p>
- * A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
- * </p>
- * <p>
- * The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
- * </p>
- * <pre>
- * StringUtils.indexOfAny(null, 0, *) = -1
- * StringUtils.indexOfAny("", 0, *) = -1
- * StringUtils.indexOfAny(*, 0, null) = -1
- * StringUtils.indexOfAny(*, 0, []) = -1
- * StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
- * StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
- * StringUtils.indexOfAny("aba", 0, ['z']) = -1
- * </pre>
- *
- * @param cs the CharSequence to check, may be null.
- * @param csStart Start searching the input {@code cs} at this index.
- * @param searchChars the chars to search for, may be null.
- * @return the index of any of the chars, -1 if no match or null input.
- * @since 2.0
- * @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
- */
- public static int indexOfAny(final CharSequence cs, final int csStart, final char... searchChars) {
- if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
- return INDEX_NOT_FOUND;
- }
- final int csLen = cs.length();
- final int csLast = csLen - 1;
- final int searchLen = searchChars.length;
- final int searchLast = searchLen - 1;
- for (int i = csStart; i < csLen; i++) {
- final char ch = cs.charAt(i);
- for (int j = 0; j < searchLen; j++) {
- if (searchChars[j] == ch) {
- // ch is a supplementary character
- if (i >= csLast || j >= searchLast || !Character.isHighSurrogate(ch) || searchChars[j + 1] == cs.charAt(i + 1)) {
- return i;
- }
- }
- }
- }
- return INDEX_NOT_FOUND;
- }
-
/**
* Find the first index of any of a set of potential substrings.
*
@@ -2805,6 +2757,54 @@ public static int indexOfAny(final CharSequence str, final CharSequence... searc
return ret == Integer.MAX_VALUE ? INDEX_NOT_FOUND : ret;
}
+ /**
+ * Search a CharSequence to find the first index of any character in the given set of characters.
+ *
+ * <p>
+ * A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
+ * </p>
+ * <p>
+ * The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
+ * </p>
+ * <pre>
+ * StringUtils.indexOfAny(null, 0, *) = -1
+ * StringUtils.indexOfAny("", 0, *) = -1
+ * StringUtils.indexOfAny(*, 0, null) = -1
+ * StringUtils.indexOfAny(*, 0, []) = -1
+ * StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
+ * StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
+ * StringUtils.indexOfAny("aba", 0, ['z']) = -1
+ * </pre>
+ *
+ * @param cs the CharSequence to check, may be null.
+ * @param csStart Start searching the input {@code cs} at this index.
+ * @param searchChars the chars to search for, may be null.
+ * @return the index of any of the chars, -1 if no match or null input.
+ * @since 2.0
+ * @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
+ */
+ public static int indexOfAny(final CharSequence cs, final int csStart, final char... searchChars) {
+ if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
+ return INDEX_NOT_FOUND;
+ }
+ final int csLen = cs.length();
+ final int csLast = csLen - 1;
+ final int searchLen = searchChars.length;
+ final int searchLast = searchLen - 1;
+ for (int i = csStart; i < csLen; i++) {
+ final char ch = cs.charAt(i);
+ for (int j = 0; j < searchLen; j++) {
+ if (searchChars[j] == ch) {
+ // ch is a supplementary character
+ if (i >= csLast || j >= searchLast || !Character.isHighSurrogate(ch) || searchChars[j + 1] == cs.charAt(i + 1)) {
+ return i;
+ }
+ }
+ }
+ }
+ return INDEX_NOT_FOUND;
+ }
+
/**
* Search a CharSequence to find the first index of any character in the given set of characters.
*
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 85ca064a9..4fc29b0d7 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -95,30 +95,6 @@ private static int distance(final Class<?>[] fromClassArray, final Class<?>[] to
return answer;
}
- /**
- * Gets an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return
- * {@code null}. This is just a convenience wrapper for {@link #getAccessibleMethod(Method)}.
- *
- * @param cls get method from this class.
- * @param methodName get method with this name.
- * @param parameterTypes with these parameters types.
- * @return The accessible method.
- */
- public static Method getAccessibleMethod(final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
- return getAccessibleMethod(getMethodObject(cls, methodName, parameterTypes));
- }
-
- /**
- * Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return
- * {@code null}.
- *
- * @param method The method that we wish to call, may be null.
- * @return The accessible method
- */
- public static Method getAccessibleMethod(final Method method) {
- return method != null ? getAccessibleMethod(method.getDeclaringClass(), method) : null;
- }
-
/**
* Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return
* {@code null}.
@@ -144,6 +120,30 @@ public static Method getAccessibleMethod(final Class<?> cls, final Method method
return method2 != null ? method2 : getAccessibleMethodFromSuperclass(cls, methodName, parameterTypes);
}
+ /**
+ * Gets an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return
+ * {@code null}. This is just a convenience wrapper for {@link #getAccessibleMethod(Method)}.
+ *
+ * @param cls get method from this class.
+ * @param methodName get method with this name.
+ * @param parameterTypes with these parameters types.
+ * @return The accessible method.
+ */
+ public static Method getAccessibleMethod(final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
+ return getAccessibleMethod(getMethodObject(cls, methodName, parameterTypes));
+ }
+
+ /**
+ * Gets an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return
+ * {@code null}.
+ *
+ * @param method The method that we wish to call, may be null.
+ * @return The accessible method
+ */
+ public static Method getAccessibleMethod(final Method method) {
+ return method != null ? getAccessibleMethod(method.getDeclaringClass(), method) : null;
+ }
+
/**
* Gets an accessible method (that is, one that can be invoked via
* reflection) that implements the specified method, by scanning through