Reuse Objects.equals() in org.apache.commons.collections4.list
This commit is contained in:
parent
c147999658
commit
38f1346176
|
@ -45,6 +45,7 @@
|
|||
<action type="fix" dev="ggregory" due-to="Gary Gregory" issue="COLLECTIONS-815">Javadoc: Update ClosureUtils Javadoc to match runtime.</action>
|
||||
<action type="fix" dev="ggregory" due-to="Gary Gregory" issue="COLLECTIONS-777">Migrate to JUnit 5.</action>
|
||||
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix NullPointerException in FilterIterator.setNextObject().</action>
|
||||
<action type="fix" dev="ggregory" due-to="Gary Gregory">EqualPredicate.test(Object) should return true if the parameter is the same object as given the constructor.</action>
|
||||
<!-- ADD -->
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory">LayerManager.Builder implements Supplier.</action>
|
||||
<action type="add" dev="ggregory" due-to="Gary Gregory, hemanth0525">Add CollectionUtils.duplicateList(Collection).</action>
|
||||
|
|
|
@ -181,7 +181,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
final Object key = entry.getKey();
|
||||
if (parent.containsKey(key)) {
|
||||
final V value = parent.normalMap.get(key);
|
||||
if (value == null ? entry.getValue() == null : value.equals(entry.getValue())) {
|
||||
if (Objects.equals(value, entry.getValue())) {
|
||||
parent.normalMap.remove(key);
|
||||
parent.reverseMap.remove(value);
|
||||
return true;
|
||||
|
|
|
@ -231,7 +231,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
|
||||
final Object value = entry.getValue();
|
||||
final Node<K, V> node = lookupKey(entry.getKey());
|
||||
return node != null && node.getValue().equals(value);
|
||||
return node != null && Objects.equals(node.getValue(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -247,7 +247,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
|
||||
final Object value = entry.getValue();
|
||||
final Node<K, V> node = lookupKey(entry.getKey());
|
||||
if (node != null && node.getValue().equals(value)) {
|
||||
if (node != null && Objects.equals(node.getValue(), value)) {
|
||||
doRedBlackDelete(node);
|
||||
return true;
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
|
||||
final Object value = entry.getValue();
|
||||
final Node<K, V> node = lookupValue(entry.getKey());
|
||||
return node != null && node.getKey().equals(value);
|
||||
return node != null && Objects.equals(node.getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -440,7 +440,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
|
||||
final Object value = entry.getValue();
|
||||
final Node<K, V> node = lookupValue(entry.getKey());
|
||||
if (node != null && node.getKey().equals(value)) {
|
||||
if (node != null && Objects.equals(node.getKey(), value)) {
|
||||
doRedBlackDelete(node);
|
||||
return true;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
return false;
|
||||
}
|
||||
final Map.Entry<?, ?> e = (Map.Entry<?, ?>) obj;
|
||||
return getKey().equals(e.getKey()) && getValue().equals(e.getValue());
|
||||
return Objects.equals(getKey(), e.getKey()) && Objects.equals(getValue(), e.getValue());
|
||||
}
|
||||
|
||||
private Object getData(final DataElement dataElement) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.collections4.functors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.Transformer;
|
||||
|
||||
|
@ -92,7 +93,7 @@ public class ConstantTransformer<T, R> implements Transformer<T, R>, Serializabl
|
|||
return false;
|
||||
}
|
||||
final Object otherConstant = ((ConstantTransformer<?, ?>) obj).getConstant();
|
||||
return otherConstant == getConstant() || otherConstant != null && otherConstant.equals(getConstant());
|
||||
return Objects.equals(otherConstant, getConstant());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.collections4.keyvalue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Abstract Pair class to assist with creating correct
|
||||
|
@ -55,9 +56,8 @@ public abstract class AbstractMapEntry<K, V> extends AbstractKeyValue<K, V> impl
|
|||
return false;
|
||||
}
|
||||
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
|
||||
return
|
||||
(getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
|
||||
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
|
||||
return Objects.equals(getKey(), other.getKey()) &&
|
||||
Objects.equals(getValue(), other.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.commons.collections4.keyvalue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.KeyValue;
|
||||
|
||||
|
@ -91,8 +92,8 @@ public class DefaultKeyValue<K, V> extends AbstractKeyValue<K, V> {
|
|||
|
||||
final DefaultKeyValue<?, ?> other = (DefaultKeyValue<?, ?>) obj;
|
||||
return
|
||||
(getKey() == null ? other.getKey() == null : getKey().equals(other.getKey())) &&
|
||||
(getValue() == null ? other.getValue() == null : getValue().equals(other.getValue()));
|
||||
Objects.equals(getKey(), other.getKey()) &&
|
||||
Objects.equals(getValue(), other.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.commons.collections4.keyvalue;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.KeyValue;
|
||||
|
||||
|
@ -71,10 +72,9 @@ public class TiedMapEntry<K, V> implements Map.Entry<K, V>, KeyValue<K, V>, Seri
|
|||
return false;
|
||||
}
|
||||
final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
|
||||
final Object value = getValue();
|
||||
return
|
||||
(key == null ? other.getKey() == null : key.equals(other.getKey())) &&
|
||||
(value == null ? other.getValue() == null : value.equals(other.getValue()));
|
||||
Objects.equals(key, other.getKey()) &&
|
||||
Objects.equals(getValue(), other.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue