Class GremlinValueComparator
java.lang.Object
org.apache.tinkerpop.gremlin.util.GremlinValueComparator
- All Implemented Interfaces:
Comparator<Object>
An implementation of the Comparability/Orderability semantics as defined in the Apache TinkerPop Provider
documentation.
- Author:
- Mike Personick (http://github.com/mikepersonick)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GremlinValueComparatorComparability has very similar semantics to orderability with the following exceptions: 1.static final GremlinValueComparatorOrderability comparator allows for a total order across all types (no type error exceptions). -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancomparable(Object f, Object s) Return true if the two objects are of the same comparison type (although they may not be the exact same Class)protected Comparatorabstract intCompare(a,b) is defined differently for Comparablity vs.abstract booleanEquals(a,b) is defined differently for Comparablity (equality) vs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
ORDERABILITY
Orderability comparator allows for a total order across all types (no type error exceptions). -
COMPARABILITY
Comparability has very similar semantics to orderability with the following exceptions: 1. NaN is not equal to anything, including itself, and cannot be compared to anything: equals(NaN, anything) = FALSE compare(NaN, anything) = ERROR 2. Unlike Orderability, Comparability is limited to a single type space: compare(type1, type2) = ERROR Note that because of type errors for Comparability, equals(a,b) does not necessarily produce the same result as compare(a,b) == 0. Make sure to use equals(a,b) for P.eq/neq.
-
-
Method Details
-
comparable
Return true if the two objects are of the same comparison type (although they may not be the exact same Class) -
comparator
-
compare
Compare(a,b) is defined differently for Comparablity vs. Orderability.- Specified by:
comparein interfaceComparator<Object>
-
equals
Equals(a,b) is defined differently for Comparablity (equality) vs. Orderability (equivalence).
-