commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r897421 - in /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder: CompareToBuilder.java EqualsBuilder.java HashCodeBuilder.java
Date Sat, 09 Jan 2010 11:44:06 GMT
Author: bayard
Date: Sat Jan  9 11:44:06 2010
New Revision: 897421

URL: http://svn.apache.org/viewvc?rev=897421&view=rev
Log:
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

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java?rev=897421&r1=897420&r2=897421&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java
Sat Jan  9 11:44:06 2010
@@ -25,6 +25,8 @@
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.commons.lang3.ArrayUtils;
+
 /** 
  * Assists in implementing {@link java.lang.Comparable#compareTo(Object)} methods.
  *
@@ -353,11 +355,10 @@
         String[] excludeFields) {
         
         Field[] fields = clazz.getDeclaredFields();
-        List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
: Collections.<String>emptyList();
         AccessibleObject.setAccessible(fields, true);
         for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
             Field f = fields[i];
-            if (!excludedFieldList.contains(f.getName())
+            if (!ArrayUtils.contains(excludeFields, f.getName())
                 && (f.getName().indexOf('$') == -1)
                 && (useTransients || !Modifier.isTransient(f.getModifiers()))
                 && (!Modifier.isStatic(f.getModifiers()))) {

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java?rev=897421&r1=897420&r2=897421&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java
Sat Jan  9 11:44:06 2010
@@ -24,6 +24,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.lang3.ArrayUtils;
+
 /**
  * <p>Assists in implementing {@link Object#equals(Object)} methods.</p>
  *
@@ -318,11 +320,10 @@
         boolean useTransients,
         String[] excludeFields) {
         Field[] fields = clazz.getDeclaredFields();
-        List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
: Collections.<String>emptyList();
         AccessibleObject.setAccessible(fields, true);
         for (int i = 0; i < fields.length && builder.isEquals; i++) {
             Field f = fields[i];
-            if (!excludedFieldList.contains(f.getName())
+            if (!ArrayUtils.contains(excludeFields, f.getName())
                 && (f.getName().indexOf('$') == -1)
                 && (useTransients || !Modifier.isTransient(f.getModifiers()))
                 && (!Modifier.isStatic(f.getModifiers()))) {

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java?rev=897421&r1=897420&r2=897421&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java
Sat Jan  9 11:44:06 2010
@@ -27,6 +27,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang3.ArrayUtils;
+
 /**
  * <p>
  * Assists in implementing {@link Object#hashCode()} methods.
@@ -179,10 +181,9 @@
         try {
             register(object);
             Field[] fields = clazz.getDeclaredFields();
-            List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
: Collections.<String>emptyList();
             AccessibleObject.setAccessible(fields, true);
             for (Field field : fields) {
-                if (!excludedFieldList.contains(field.getName())
+                if (!ArrayUtils.contains(excludeFields, field.getName())
                     && (field.getName().indexOf('$') == -1)
                     && (useTransients || !Modifier.isTransient(field.getModifiers()))
                     && (!Modifier.isStatic(field.getModifiers()))) {



Mime
View raw message