Class GremlinValueComparator
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.util.GremlinValueComparator
-
- All Implemented Interfaces:
Comparator<Object>
public abstract class GremlinValueComparator extends Object implements 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 Modifier and Type Class Description static class
GremlinValueComparator.Type
The typespace.
-
Field Summary
Fields Modifier and Type Field Description static GremlinValueComparator
COMPARABILITY
Comparability has very similar semantics to orderability with the following exceptions: 1.static GremlinValueComparator
ORDERABILITY
Orderability comparator allows for a total order across all types (no type error exceptions).
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Comparator
comparator(GremlinValueComparator.Type type)
abstract int
compare(Object f, Object s)
Compare(a,b) is defined differently for Comparablity vs.abstract boolean
equals(Object f, Object s)
Equals(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, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Field Detail
-
ORDERABILITY
public static final GremlinValueComparator ORDERABILITY
Orderability comparator allows for a total order across all types (no type error exceptions).
-
COMPARABILITY
public static final GremlinValueComparator 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 Detail
-
comparator
protected Comparator comparator(GremlinValueComparator.Type type)
-
compare
public abstract int compare(Object f, Object s)
Compare(a,b) is defined differently for Comparablity vs. Orderability.- Specified by:
compare
in interfaceComparator<Object>
-
-