Replacing the creation of a List in the core of each Builder class to test contains on the excludeFields with a call to ArrayUtils.contains. Reported by Anthony Whitford in LANG-575
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@897421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d518b7786
commit
5494a87bbb
|
@ -25,6 +25,8 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assists in implementing {@link java.lang.Comparable#compareTo(Object)} methods.
|
* Assists in implementing {@link java.lang.Comparable#compareTo(Object)} methods.
|
||||||
*
|
*
|
||||||
|
@ -353,11 +355,10 @@ public class CompareToBuilder {
|
||||||
String[] excludeFields) {
|
String[] excludeFields) {
|
||||||
|
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.<String>emptyList();
|
|
||||||
AccessibleObject.setAccessible(fields, true);
|
AccessibleObject.setAccessible(fields, true);
|
||||||
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
|
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
|
||||||
Field f = fields[i];
|
Field f = fields[i];
|
||||||
if (!excludedFieldList.contains(f.getName())
|
if (!ArrayUtils.contains(excludeFields, f.getName())
|
||||||
&& (f.getName().indexOf('$') == -1)
|
&& (f.getName().indexOf('$') == -1)
|
||||||
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
||||||
&& (!Modifier.isStatic(f.getModifiers()))) {
|
&& (!Modifier.isStatic(f.getModifiers()))) {
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Assists in implementing {@link Object#equals(Object)} methods.</p>
|
* <p>Assists in implementing {@link Object#equals(Object)} methods.</p>
|
||||||
*
|
*
|
||||||
|
@ -318,11 +320,10 @@ public class EqualsBuilder {
|
||||||
boolean useTransients,
|
boolean useTransients,
|
||||||
String[] excludeFields) {
|
String[] excludeFields) {
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.<String>emptyList();
|
|
||||||
AccessibleObject.setAccessible(fields, true);
|
AccessibleObject.setAccessible(fields, true);
|
||||||
for (int i = 0; i < fields.length && builder.isEquals; i++) {
|
for (int i = 0; i < fields.length && builder.isEquals; i++) {
|
||||||
Field f = fields[i];
|
Field f = fields[i];
|
||||||
if (!excludedFieldList.contains(f.getName())
|
if (!ArrayUtils.contains(excludeFields, f.getName())
|
||||||
&& (f.getName().indexOf('$') == -1)
|
&& (f.getName().indexOf('$') == -1)
|
||||||
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
||||||
&& (!Modifier.isStatic(f.getModifiers()))) {
|
&& (!Modifier.isStatic(f.getModifiers()))) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Assists in implementing {@link Object#hashCode()} methods.
|
* Assists in implementing {@link Object#hashCode()} methods.
|
||||||
|
@ -179,10 +181,9 @@ public class HashCodeBuilder {
|
||||||
try {
|
try {
|
||||||
register(object);
|
register(object);
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.<String>emptyList();
|
|
||||||
AccessibleObject.setAccessible(fields, true);
|
AccessibleObject.setAccessible(fields, true);
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
if (!excludedFieldList.contains(field.getName())
|
if (!ArrayUtils.contains(excludeFields, field.getName())
|
||||||
&& (field.getName().indexOf('$') == -1)
|
&& (field.getName().indexOf('$') == -1)
|
||||||
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
|
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
|
||||||
&& (!Modifier.isStatic(field.getModifiers()))) {
|
&& (!Modifier.isStatic(field.getModifiers()))) {
|
||||||
|
|
Loading…
Reference in New Issue