Class NumberHelper
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.util.NumberHelper
 
- 
 public final class NumberHelper extends Object - Author:
- Daniel Kuppitz (http://gremlin.guru)
 
- 
- 
Field SummaryFields Modifier and Type Field Description BiFunction<Number,Number,Number>addBiFunction<Number,Number,Integer>cmpBiFunction<Number,Number,Number>divBiFunction<Number,Number,Number>maxBiFunction<Number,Number,Number>minBiFunction<Number,Number,Number>mulBiFunction<Number,Number,Number>sub
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static Numberadd(Number a, Number b)Adds two numbers returning the highest common number class between them.static booleanbothAreNaN(Object first, Object second)static Integercompare(Number a, Number b)Compares two numbers.static Numberdiv(Number a, Number b)Divides two numbers returning the highest common number class between them callingdiv(Number, Number, boolean)with afalse.static Numberdiv(Number a, Number b, boolean forceFloatingPoint)Divides two numbers returning the highest common number class between them.static booleaneitherAreNaN(Object first, Object second)static Class<? extends Number>getHighestCommonNumberClass(boolean forceFloatingPoint, Number... numbers)static Class<? extends Number>getHighestCommonNumberClass(Number... numbers)static booleanisNaN(Object object)static booleanisNegativeInfinity(Object value)static booleanisPositiveInfinity(Object value)static Comparablemax(Comparable a, Comparable b)Gets the larger number of the two provided returning the highest common number class between them.static Numbermax(Number a, Number b)Gets the larger number of the two provided returning the highest common number class between them.static Comparablemin(Comparable a, Comparable b)Gets the smaller number of the two provided returning the highest common number class between them.static Numbermin(Number a, Number b)Gets the smaller number of the two provided returning the highest common number class between them.static Numbermul(Number a, Number b)Multiplies two numbers returning the highest common number class between them.static Numbersub(Number a, Number b)Subtracts two numbers returning the highest common number class between them.
 
- 
- 
- 
Field Detail- 
addpublic final BiFunction<Number,Number,Number> add 
 - 
subpublic final BiFunction<Number,Number,Number> sub 
 - 
mulpublic final BiFunction<Number,Number,Number> mul 
 - 
divpublic final BiFunction<Number,Number,Number> div 
 - 
minpublic final BiFunction<Number,Number,Number> min 
 - 
maxpublic final BiFunction<Number,Number,Number> max 
 - 
cmppublic final BiFunction<Number,Number,Integer> cmp 
 
- 
 - 
Method Detail- 
getHighestCommonNumberClasspublic static Class<? extends Number> getHighestCommonNumberClass(Number... numbers) 
 - 
getHighestCommonNumberClasspublic static Class<? extends Number> getHighestCommonNumberClass(boolean forceFloatingPoint, Number... numbers) 
 - 
addpublic static Number add(Number a, Number b) Adds two numbers returning the highest common number class between them.a = 1, b = 1 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null- Parameters:
- a- should be thought of as the seed to be modified by- b
- b- the modifier to {code a}
 
 - 
subpublic static Number sub(Number a, Number b) Subtracts two numbers returning the highest common number class between them.a = 1, b = 1 -> 0 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null- Parameters:
- a- should be thought of as the seed to be modified by- b
- b- the modifier to {code a}
 
 - 
mulpublic static Number mul(Number a, Number b) Multiplies two numbers returning the highest common number class between them.a = 1, b = 2 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null- Parameters:
- a- should be thought of as the seed to be modified by- b
- b- the modifier to {code a}
 
 - 
divpublic static Number div(Number a, Number b) Divides two numbers returning the highest common number class between them callingdiv(Number, Number, boolean)with afalse.
 - 
divpublic static Number div(Number a, Number b, boolean forceFloatingPoint) Divides two numbers returning the highest common number class between them.a = 4, b = 2 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null- Parameters:
- a- should be thought of as the seed to be modified by- b
- b- the modifier to {code a}
- forceFloatingPoint- when set to- trueensures that the return value is the highest common floating number class
 
 - 
minpublic static Number min(Number a, Number b) Gets the smaller number of the two provided returning the highest common number class between them.a = 4, b = 2 -> 2 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null a = NaN, b = 1 -> 1 a = 1, b = NaN -> 1 a = NaN, b = NaN -> NaN
 - 
minpublic static Comparable min(Comparable a, Comparable b) Gets the smaller number of the two provided returning the highest common number class between them.a = 4, b = 2 -> 2 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null a = NaN, b = 1 -> 1 a = 1, b = NaN -> 1 a = NaN, b = NaN -> NaN
 - 
maxpublic static Number max(Number a, Number b) Gets the larger number of the two provided returning the highest common number class between them.a = 4, b = 2 -> 4 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null a = NaN, b = 1 -> 1 a = 1, b = NaN -> 1 a = NaN, b = NaN -> NaN
 - 
maxpublic static Comparable max(Comparable a, Comparable b) Gets the larger number of the two provided returning the highest common number class between them.a = 4, b = 2 -> 4 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null a = NaN, b = 1 -> 1 a = 1, b = NaN -> 1 a = NaN, b = NaN -> NaN
 - 
comparepublic static Integer compare(Number a, Number b) Compares two numbers. Follows orderability semantics for NaN, which places NaN after +Inf.a = 4, b = 2 -> 1 a = 2, b = 4 -> -1 a = null, b = 1 -> -1 a = 1, b = null -> 1 a = null, b = null -> 0 a = NaN, b = NaN -> 0 a = NaN, b = Inf -> 1
 - 
isNaNpublic static boolean isNaN(Object object) 
 - 
isPositiveInfinitypublic static boolean isPositiveInfinity(Object value) 
 - 
isNegativeInfinitypublic static boolean isNegativeInfinity(Object value) 
 
- 
 
-