Use ArraySorter.
This commit is contained in:
parent
5aab41b365
commit
44b0bb5273
|
@ -5231,8 +5231,7 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
static Object removeAll(final Object array, final int... indices) {
|
||||
final int length = getLength(array);
|
||||
int diff = 0; // number of distinct indexes, i.e. number of entries that will be removed
|
||||
final int[] clonedIndices = clone(indices);
|
||||
Arrays.sort(clonedIndices);
|
||||
final int[] clonedIndices = ArraySorter.sort(clone(indices));
|
||||
|
||||
// identify length of result array
|
||||
if (isNotEmpty(clonedIndices)) {
|
||||
|
|
|
@ -20,12 +20,12 @@ package org.apache.commons.lang3.builder;
|
|||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.ArraySorter;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
|
@ -191,8 +191,7 @@ public class HashCodeBuilder implements Builder<Integer> {
|
|||
try {
|
||||
register(object);
|
||||
// The elements in the returned array are not sorted and are not in any particular order.
|
||||
final Field[] fields = clazz.getDeclaredFields();
|
||||
Arrays.sort(fields, Comparator.comparing(Field::getName));
|
||||
final Field[] fields = ArraySorter.sort(clazz.getDeclaredFields(), Comparator.comparing(Field::getName));
|
||||
AccessibleObject.setAccessible(fields, true);
|
||||
for (final Field field : fields) {
|
||||
if (!ArrayUtils.contains(excludeFields, field.getName())
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArraySorter;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
@ -640,8 +641,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
|
|||
return;
|
||||
}
|
||||
// The elements in the returned array are not sorted and are not in any particular order.
|
||||
final Field[] fields = clazz.getDeclaredFields();
|
||||
Arrays.sort(fields, Comparator.comparing(Field::getName));
|
||||
final Field[] fields = ArraySorter.sort(clazz.getDeclaredFields(), Comparator.comparing(Field::getName));
|
||||
AccessibleObject.setAccessible(fields, true);
|
||||
for (final Field field : fields) {
|
||||
final String fieldName = field.getName();
|
||||
|
@ -801,8 +801,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
|
|||
this.excludeFieldNames = null;
|
||||
} else {
|
||||
//clone and remove nulls
|
||||
this.excludeFieldNames = toNoNullStringArray(excludeFieldNamesParam);
|
||||
Arrays.sort(this.excludeFieldNames);
|
||||
this.excludeFieldNames = ArraySorter.sort(toNoNullStringArray(excludeFieldNamesParam));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.commons.lang3.text;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.lang3.ArraySorter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
|
@ -284,8 +285,7 @@ public abstract class StrMatcher {
|
|||
* @param chars the characters to match, must not be null
|
||||
*/
|
||||
CharSetMatcher(final char[] chars) {
|
||||
this.chars = chars.clone();
|
||||
Arrays.sort(this.chars);
|
||||
this.chars = ArraySorter.sort(chars.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue