Skip to content

Commit d575811

Browse files
committed
Sort members
1 parent eaf4d61 commit d575811

File tree

2 files changed

+72
-72
lines changed

2 files changed

+72
-72
lines changed

src/main/java/org/apache/commons/lang3/StringUtils.java

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,54 +2708,6 @@ public static int indexOfAny(final CharSequence cs, final char... searchChars) {
27082708
return indexOfAny(cs, 0, searchChars);
27092709
}
27102710

2711-
/**
2712-
* Search a CharSequence to find the first index of any character in the given set of characters.
2713-
*
2714-
* <p>
2715-
* A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
2716-
* </p>
2717-
* <p>
2718-
* The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
2719-
* </p>
2720-
* <pre>
2721-
* StringUtils.indexOfAny(null, 0, *) = -1
2722-
* StringUtils.indexOfAny("", 0, *) = -1
2723-
* StringUtils.indexOfAny(*, 0, null) = -1
2724-
* StringUtils.indexOfAny(*, 0, []) = -1
2725-
* StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
2726-
* StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
2727-
* StringUtils.indexOfAny("aba", 0, ['z']) = -1
2728-
* </pre>
2729-
*
2730-
* @param cs the CharSequence to check, may be null.
2731-
* @param csStart Start searching the input {@code cs} at this index.
2732-
* @param searchChars the chars to search for, may be null.
2733-
* @return the index of any of the chars, -1 if no match or null input.
2734-
* @since 2.0
2735-
* @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
2736-
*/
2737-
public static int indexOfAny(final CharSequence cs, final int csStart, final char... searchChars) {
2738-
if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
2739-
return INDEX_NOT_FOUND;
2740-
}
2741-
final int csLen = cs.length();
2742-
final int csLast = csLen - 1;
2743-
final int searchLen = searchChars.length;
2744-
final int searchLast = searchLen - 1;
2745-
for (int i = csStart; i < csLen; i++) {
2746-
final char ch = cs.charAt(i);
2747-
for (int j = 0; j < searchLen; j++) {
2748-
if (searchChars[j] == ch) {
2749-
// ch is a supplementary character
2750-
if (i >= csLast || j >= searchLast || !Character.isHighSurrogate(ch) || searchChars[j + 1] == cs.charAt(i + 1)) {
2751-
return i;
2752-
}
2753-
}
2754-
}
2755-
}
2756-
return INDEX_NOT_FOUND;
2757-
}
2758-
27592711
/**
27602712
* Find the first index of any of a set of potential substrings.
27612713
*
@@ -2805,6 +2757,54 @@ public static int indexOfAny(final CharSequence str, final CharSequence... searc
28052757
return ret == Integer.MAX_VALUE ? INDEX_NOT_FOUND : ret;
28062758
}
28072759

2760+
/**
2761+
* Search a CharSequence to find the first index of any character in the given set of characters.
2762+
*
2763+
* <p>
2764+
* A {@code null} String will return {@code -1}. A {@code null} or zero length search array will return {@code -1}.
2765+
* </p>
2766+
* <p>
2767+
* The following is the same as {@code indexOfAny(cs, 0, searchChars)}.
2768+
* </p>
2769+
* <pre>
2770+
* StringUtils.indexOfAny(null, 0, *) = -1
2771+
* StringUtils.indexOfAny("", 0, *) = -1
2772+
* StringUtils.indexOfAny(*, 0, null) = -1
2773+
* StringUtils.indexOfAny(*, 0, []) = -1
2774+
* StringUtils.indexOfAny("zzabyycdxx", 0, ['z', 'a']) = 0
2775+
* StringUtils.indexOfAny("zzabyycdxx", 0, ['b', 'y']) = 3
2776+
* StringUtils.indexOfAny("aba", 0, ['z']) = -1
2777+
* </pre>
2778+
*
2779+
* @param cs the CharSequence to check, may be null.
2780+
* @param csStart Start searching the input {@code cs} at this index.
2781+
* @param searchChars the chars to search for, may be null.
2782+
* @return the index of any of the chars, -1 if no match or null input.
2783+
* @since 2.0
2784+
* @since 3.0 Changed signature from indexOfAny(String, char[]) to indexOfAny(CharSequence, char...)
2785+
*/
2786+
public static int indexOfAny(final CharSequence cs, final int csStart, final char... searchChars) {
2787+
if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {
2788+
return INDEX_NOT_FOUND;
2789+
}
2790+
final int csLen = cs.length();
2791+
final int csLast = csLen - 1;
2792+
final int searchLen = searchChars.length;
2793+
final int searchLast = searchLen - 1;
2794+
for (int i = csStart; i < csLen; i++) {
2795+
final char ch = cs.charAt(i);
2796+
for (int j = 0; j < searchLen; j++) {
2797+
if (searchChars[j] == ch) {
2798+
// ch is a supplementary character
2799+
if (i >= csLast || j >= searchLast || !Character.isHighSurrogate(ch) || searchChars[j + 1] == cs.charAt(i + 1)) {
2800+
return i;
2801+
}
2802+
}
2803+
}
2804+
}
2805+
return INDEX_NOT_FOUND;
2806+
}
2807+
28082808
/**
28092809
* Search a CharSequence to find the first index of any character in the given set of characters.
28102810
*

src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,30 +95,6 @@ private static int distance(final Class<?>[] fromClassArray, final Class<?>[] to
9595
return answer;
9696
}
9797

98-
/**
99-
* 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
100-
* {@code null}. This is just a convenience wrapper for {@link #getAccessibleMethod(Method)}.
101-
*
102-
* @param cls get method from this class.
103-
* @param methodName get method with this name.
104-
* @param parameterTypes with these parameters types.
105-
* @return The accessible method.
106-
*/
107-
public static Method getAccessibleMethod(final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
108-
return getAccessibleMethod(getMethodObject(cls, methodName, parameterTypes));
109-
}
110-
111-
/**
112-
* 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
113-
* {@code null}.
114-
*
115-
* @param method The method that we wish to call, may be null.
116-
* @return The accessible method
117-
*/
118-
public static Method getAccessibleMethod(final Method method) {
119-
return method != null ? getAccessibleMethod(method.getDeclaringClass(), method) : null;
120-
}
121-
12298
/**
12399
* 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
124100
* {@code null}.
@@ -144,6 +120,30 @@ public static Method getAccessibleMethod(final Class<?> cls, final Method method
144120
return method2 != null ? method2 : getAccessibleMethodFromSuperclass(cls, methodName, parameterTypes);
145121
}
146122

123+
/**
124+
* 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
125+
* {@code null}. This is just a convenience wrapper for {@link #getAccessibleMethod(Method)}.
126+
*
127+
* @param cls get method from this class.
128+
* @param methodName get method with this name.
129+
* @param parameterTypes with these parameters types.
130+
* @return The accessible method.
131+
*/
132+
public static Method getAccessibleMethod(final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
133+
return getAccessibleMethod(getMethodObject(cls, methodName, parameterTypes));
134+
}
135+
136+
/**
137+
* 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
138+
* {@code null}.
139+
*
140+
* @param method The method that we wish to call, may be null.
141+
* @return The accessible method
142+
*/
143+
public static Method getAccessibleMethod(final Method method) {
144+
return method != null ? getAccessibleMethod(method.getDeclaringClass(), method) : null;
145+
}
146+
147147
/**
148148
* Gets an accessible method (that is, one that can be invoked via
149149
* reflection) that implements the specified method, by scanning through

0 commit comments

Comments
 (0)