svn commit: r1863443 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ base/src/main/java/org/apache/ofbiz/base/util/collections/ base/src/main/java/org/apache/ofbiz/base/util/test/ base/src/test/java/org/apach...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1863443 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ base/src/main/java/org/apache/ofbiz/base/util/collections/ base/src/main/java/org/apache/ofbiz/base/util/test/ base/src/test/java/org/apach...

mthl
Author: mthl
Date: Fri Jul 19 22:11:39 2019
New Revision: 1863443

URL: http://svn.apache.org/viewvc?rev=1863443&view=rev
Log:
Improved: Remove useless ‘UtilObject#equalsHelper’
(OFBIZ-11140)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMap.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapEntry.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ReadOnlyMapEntry.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilObjectTests.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/util/cache/UtilCacheTests.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
    ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java Fri Jul 19 22:11:39 2019
@@ -112,18 +112,6 @@ public final class UtilObject {
         }
     }
 
-    public static boolean equalsHelper(Object o1, Object o2) {
-        if (o1 == o2) {
-            // handles same-reference, or null
-            return true;
-        } else if (o1 == null || o2 == null) {
-            // either o1 or o2 is null, but not both
-            return false;
-        } else {
-            return o1.equals(o2);
-        }
-    }
-
     public static <T> int compareToHelper(Comparable<T> o1, T o2) {
         if (o1 == o2) {
             // handles same-reference, or null

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java Fri Jul 19 22:11:39 2019
@@ -21,6 +21,7 @@ package org.apache.ofbiz.base.util.colle
 import java.io.Serializable;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 
 import javax.el.PropertyNotFoundException;
 
@@ -28,7 +29,6 @@ import org.apache.ofbiz.base.lang.IsEmpt
 import org.apache.ofbiz.base.lang.SourceMonitored;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.UtilGenerics;
-import org.apache.ofbiz.base.util.UtilObject;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.cache.UtilCache;
 import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
@@ -224,7 +224,7 @@ public final class FlexibleMapAccessor<T
         }
         if (obj instanceof FlexibleMapAccessor) {
             FlexibleMapAccessor<?> that = (FlexibleMapAccessor<?>) obj;
-            return UtilObject.equalsHelper(this.original, that.original);
+            return Objects.equals(this.original, that.original);
         }
         return false;
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMap.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMap.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMap.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMap.java Fri Jul 19 22:11:39 2019
@@ -30,7 +30,6 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.ofbiz.base.lang.Appender;
 import org.apache.ofbiz.base.util.UtilGenerics;
-import org.apache.ofbiz.base.util.UtilObject;
 
 @SuppressWarnings("serial")
 public abstract class GenericMap<K, V> implements Appender<StringBuilder>, Map<K, V>, Serializable {
@@ -165,7 +164,7 @@ public abstract class GenericMap<K, V> i
             entrySetUpdater.compareAndSet(this, null, new GenericMapEntrySet<K, V, GenericMap<K, V>>(this) {
                 @Override
                 protected boolean contains(Object key, Object value) {
-                    return UtilObject.equalsHelper(get(key, false), value);
+                    return Objects.equals(get(key, false), value);
                 }
 
                 @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapEntry.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapEntry.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapEntry.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapEntry.java Fri Jul 19 22:11:39 2019
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.base.util.collections;
 
 import java.util.Map;
+import java.util.Objects;
 
 import org.apache.ofbiz.base.util.UtilObject;
 
@@ -57,7 +58,7 @@ public class GenericMapEntry<K, V> imple
             return true;
         }
         Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
-        return UtilObject.equalsHelper(getKey(), other.getKey()) && UtilObject.equalsHelper(getValue(), other.getValue());
+        return Objects.equals(getKey(), other.getKey()) && Objects.equals(getValue(), other.getValue());
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java Fri Jul 19 22:11:39 2019
@@ -22,10 +22,9 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
-import org.apache.ofbiz.base.util.UtilObject;
-
 public abstract class GenericMapValues<K, V, M extends Map<K, V>> extends GenericMapCollection<K, V, M, V> {
     public GenericMapValues(M source) {
         super(source);
@@ -35,7 +34,7 @@ public abstract class GenericMapValues<K
     public boolean contains(Object item) {
         Iterator<V> it = iterator(false);
         while (it.hasNext()) {
-            if (UtilObject.equalsHelper(item, it.next())) {
+            if (Objects.equals(item, it.next())) {
                 return true;
             }
         }
@@ -82,7 +81,7 @@ public abstract class GenericMapValues<K
     public boolean remove(Object item) {
         Iterator<V> it = iterator(false);
         while (it.hasNext()) {
-            if (UtilObject.equalsHelper(item, it.next())) {
+            if (Objects.equals(item, it.next())) {
                 it.remove();
                 return true;
             }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ReadOnlyMapEntry.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ReadOnlyMapEntry.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ReadOnlyMapEntry.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/ReadOnlyMapEntry.java Fri Jul 19 22:11:39 2019
@@ -19,6 +19,7 @@
 package org.apache.ofbiz.base.util.collections;
 
 import java.util.Map;
+import java.util.Objects;
 
 import org.apache.ofbiz.base.util.UtilObject;
 
@@ -58,7 +59,7 @@ public class ReadOnlyMapEntry<K, V> impl
             return true;
         }
         Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
-        return UtilObject.equalsHelper(getKey(), other.getKey()) && UtilObject.equalsHelper(getValue(), other.getValue());
+        return Objects.equals(getKey(), other.getKey()) && Objects.equals(getValue(), other.getValue());
     }
 
     @Override

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilObjectTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilObjectTests.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilObjectTests.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilObjectTests.java Fri Jul 19 22:11:39 2019
@@ -260,16 +260,6 @@ public class UtilObjectTests extends Gen
         }
     }
 
-    public void testEqualsHelper() {
-        assertTrue("a == a", UtilObject.equalsHelper(this, this));
-        assertFalse("null == a", UtilObject.equalsHelper(null, this));
-        assertFalse("a == null", UtilObject.equalsHelper(this, null));
-        assertTrue("null == null", UtilObject.equalsHelper(null, null));
-        assertTrue("map == map", UtilObject.equalsHelper(new HashMap<String, Object>(), new HashMap<String, Object>()));
-        assertFalse("map == this", UtilObject.equalsHelper(new HashMap<String, Object>(), this));
-        assertFalse("this == map", UtilObject.equalsHelper(this, new HashMap<String, Object>()));
-    }
-
     public void testCompareToHelper() {
         Long one = 1L;
         Long two = 2L;

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/util/cache/UtilCacheTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/util/cache/UtilCacheTests.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/util/cache/UtilCacheTests.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/util/cache/UtilCacheTests.java Fri Jul 19 22:11:39 2019
@@ -34,6 +34,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.ofbiz.base.util.UtilMisc;
@@ -64,7 +65,7 @@ public class UtilCacheTests implements S
         public boolean equals(Object o) {
             if (o instanceof Removal<?>) {
                 Removal<?> other = (Removal<?>) o;
-                return UtilObject.equalsHelper(oldValue, other.oldValue);
+                return Objects.equals(oldValue, other.oldValue);
             }
             return false;
         }
@@ -86,7 +87,7 @@ public class UtilCacheTests implements S
         public boolean equals(Object o) {
             if (o instanceof Addition<?>) {
                 Addition<?> other = (Addition<?>) o;
-                return UtilObject.equalsHelper(newValue, other.newValue);
+                return Objects.equals(newValue, other.newValue);
             }
             return false;
         }
@@ -110,10 +111,10 @@ public class UtilCacheTests implements S
         public boolean equals(Object o) {
             if (o instanceof Update<?>) {
                 Update<?> other = (Update<?>) o;
-                if (!UtilObject.equalsHelper(newValue, other.newValue)) {
+                if (!Objects.equals(newValue, other.newValue)) {
                    return false;
                 }
-                return UtilObject.equalsHelper(oldValue, other.oldValue);
+                return Objects.equals(oldValue, other.oldValue);
             }
             return false;
         }

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java Fri Jul 19 22:11:39 2019
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -47,7 +48,6 @@ import org.apache.ofbiz.base.util.UtilDa
 import org.apache.ofbiz.base.util.UtilFormatOut;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilObject;
 import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.UtilXml;
@@ -1312,7 +1312,7 @@ public class GenericDelegator implements
                         if (value.containsKey(fieldName)) {
                             Object fieldValue = value.get(fieldName);
                             Object oldValue = existing.get(fieldName);
-                            if (!UtilObject.equalsHelper(oldValue, fieldValue)) {
+                            if (!Objects.equals(oldValue, fieldValue)) {
                                 toStore.put(fieldName, fieldValue);
                                 atLeastOneField = true;
                             }

Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java Fri Jul 19 22:11:39 2019
@@ -21,6 +21,7 @@ package org.apache.ofbiz.webtools.artifa
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -28,7 +29,6 @@ import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilObject;
 import org.apache.ofbiz.base.util.UtilURL;
 import org.apache.ofbiz.webapp.control.ConfigXMLReader;
 
@@ -154,7 +154,7 @@ public class ControllerRequestArtifactIn
     public boolean equals(Object obj) {
         if (obj instanceof ControllerRequestArtifactInfo) {
             ControllerRequestArtifactInfo that = (ControllerRequestArtifactInfo) obj;
-            return UtilObject.equalsHelper(this.controllerXmlUrl, that.controllerXmlUrl) && UtilObject.equalsHelper(this.requestUri, that.requestUri);
+            return Objects.equals(this.controllerXmlUrl, that.controllerXmlUrl) && Objects.equals(this.requestUri, that.requestUri);
         } else {
             return false;
         }

Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java?rev=1863443&r1=1863442&r2=1863443&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java Fri Jul 19 22:11:39 2019
@@ -20,11 +20,11 @@ package org.apache.ofbiz.webtools.artifa
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.base.util.UtilObject;
 import org.apache.ofbiz.base.util.UtilURL;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.webapp.control.ConfigXMLReader;
@@ -112,8 +112,8 @@ public class ControllerViewArtifactInfo
     public boolean equals(Object obj) {
         if (obj instanceof ControllerViewArtifactInfo) {
             ControllerViewArtifactInfo that = (ControllerViewArtifactInfo) obj;
-            return UtilObject.equalsHelper(this.controllerXmlUrl, that.controllerXmlUrl) &&
-                UtilObject.equalsHelper(this.viewUri, that.viewUri);
+            return Objects.equals(this.controllerXmlUrl, that.controllerXmlUrl) &&
+                Objects.equals(this.viewUri, that.viewUri);
         } else {
             return false;
         }