Package io.deephaven.util.compare
Class ObjectComparisons
java.lang.Object
io.deephaven.util.compare.ObjectComparisons
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intCompares two Objects according to the following rules:nullis less than all other values Otherwise,Comparable.compareTo(Object)is usedstatic booleancompareEquals(Object lhs, Object rhs) Compare two Objects for equality consistent withcompare(Object, Object); logically equivalent tocompare(lhs, rhs) == 0.static booleanCompare two Objects for equality usingObjects.equals(Object, Object); this is consistent withhashCode(Object), that iseq(x, y) => hashCode(x) == hashCode(y).static booleanLogically equivalent tocompare(lhs, rhs) >= 0.static booleanLogically equivalent tocompare(lhs, rhs) > 0.static intReturns a hash code for anObjectvalue consistent witheq(Object, Object); that is,eq(x, y) ⇒ hashCode(x) == hashCode(y).static booleanLogically equivalent tocompare(lhs, rhs) <= 0.static booleanLogically equivalent tocompare(lhs, rhs) < 0.
-
Constructor Details
-
ObjectComparisons
public ObjectComparisons()
-
-
Method Details
-
compare
Compares two Objects according to the following rules:nullis less than all other values- Otherwise,
Comparable.compareTo(Object)is used
- Parameters:
lhs- the first valuerhs- the second value- Returns:
- the value
0iflhsis equal torhs; a value less than0iflhsis less thanrhs; and a value greater than0iflhsis greater thanrhs
-
eq
Compare two Objects for equality usingObjects.equals(Object, Object); this is consistent withhashCode(Object), that iseq(x, y) => hashCode(x) == hashCode(y).For types whose
compareTois not consistent withequals(e.g.,BigDecimal1.0 and 1.00),eqmay be false for values wherecompare(lhs, rhs) == 0. UsecompareEquals(Object, Object)for equality that is consistent withcompare(Object, Object).- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueif the values are equal,falseotherwise
-
compareEquals
Compare two Objects for equality consistent withcompare(Object, Object); logically equivalent tocompare(lhs, rhs) == 0.This equality is suitable for any ordering in which distinct objects that are not
equalsmay share an equivalence class (e.g.,BigDecimal1.0 and 1.00). Unlikeeq(Object, Object), it is not consistent withhashCode(Object), so it must not be used for hashing.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifcompare(lhs, rhs) == 0,falseotherwise
-
hashCode
Returns a hash code for anObjectvalue consistent witheq(Object, Object); that is,eq(x, y) ⇒ hashCode(x) == hashCode(y).- Parameters:
x- the value to hash- Returns:
- a hash code value for an
Objectvalue
-
gt
Logically equivalent tocompare(lhs, rhs) > 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis greater thanrhs
-
lt
Logically equivalent tocompare(lhs, rhs) < 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis less thanrhs
-
geq
Logically equivalent tocompare(lhs, rhs) >= 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis greater than or equal torhs
-
leq
Logically equivalent tocompare(lhs, rhs) <= 0.- Parameters:
lhs- the first valuerhs- the second value- Returns:
trueifflhsis less than or equal torhs
-