- All Implemented Interfaces:
Serializable,Comparable<CompareOperator>,java.lang.constant.Constable
A
CompareOperator represents an operator able to compare two
given values.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCompareOperatorto check if objects areequal.CompareOperatorto check if some value is greater or equal to another.CompareOperatorto check if some value is greater than another.CompareOperatorto check if some value is less or equal than another.CompareOperatorto check if some value is less than another.CompareOperatorto check if objects are NOTequal. -
Method Summary
Modifier and TypeMethodDescription<T extends Comparable<T>>
booleanevalComparable(T arg1, T arg2) This method evaluates thisCompareOperatorfor the givenComparablearguments.abstract booleanevalDelta(int delta) booleanevalDouble(double arg1, double arg2) This method evaluates thisCompareOperatorfor the given arguments.booleanevalNumber(Number arg1, Number arg2) This method evaluates thisCompareOperatorfor the givenNumberarguments.booleanevalObject(Object arg1, Object arg2) Generic variant ofevalComparable(Comparable, Comparable)that tries to convert incompatible arguments: If both arguments are same it will returnevalDelta(0). If only exactly one of the arguments isnullit will returnevalDelta(Integer.MIN_VALUE). If both arguments areNumbers it delegates toevalNumber(Number, Number)If both arguments areComparables: If bothComparables have different types but each of them is a standardTemporalorDate/Calendar, then one of them is converted to the other.abstract CompareOperatornegate()static CompareOperatorThis method gets theCompareOperatorfor the givensymbol.toString()static CompareOperatorReturns the enum constant of this type with the specified name.static CompareOperator[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
GREATER_THAN
CompareOperatorto check if some value is greater than another. -
GREATER_OR_EQUAL
CompareOperatorto check if some value is greater or equal to another. -
LESS_THAN
CompareOperatorto check if some value is less than another. -
LESS_OR_EQUAL
CompareOperatorto check if some value is less or equal than another. -
EQUAL
CompareOperatorto check if objects areequal. -
NOT_EQUAL
CompareOperatorto check if objects are NOTequal.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getSymbol
- Returns:
- the symbol of this
CompareOperator("==", ">", ">=", "<", or "<=")
-
negate
- Returns:
- the negation of this
CompareOperatorthatevaluatesto the negated result.
-
evalDelta
public abstract boolean evalDelta(int delta) - Parameters:
delta- the signum ofComparable.compareTo(Object)orInteger.MIN_VALUEif the arguments are incompatible (e.g. exactly one isnullorStringcompared withBoolean).- Returns:
- the result of the
CompareOperatorfor the givendelta.
-
evalDouble
public boolean evalDouble(double arg1, double arg2) This method evaluates thisCompareOperatorfor the given arguments.- Parameters:
arg1- is the first argument.arg2- is the second argument.- Returns:
- the result of the
CompareOperatorapplied to the given arguments.
-
evalComparable
This method evaluates thisCompareOperatorfor the givenComparablearguments.- Type Parameters:
T- type of theComparableobjects.- Parameters:
arg1- is the first argument.arg2- is the second argument.- Returns:
- the result of the
CompareOperatorapplied to the given arguments. - See Also:
-
evalObject
Generic variant ofevalComparable(Comparable, Comparable)that tries to convert incompatible arguments:- If both arguments are same it will return
evalDelta(0). - If only exactly one of the arguments is
nullit will returnevalDelta(Integer.MIN_VALUE). - If both arguments are
Numbers it delegates toevalNumber(Number, Number) - If both arguments are
Comparables:- If both
Comparables have different types but each of them is a standardTemporalorDate/Calendar, then one of them is converted to the other. Please note that some combinations are still invalid so e.g.LocalDateandLocalTimeare not comparable. - If we now have two
Comparables of the same type, we delegate toevalComparable(Comparable, Comparable).
- If both
- Parameters:
arg1- is the first argument.arg2- is the second argument.- Returns:
- the result of the
CompareOperatorapplied to the given arguments.
- If both arguments are same it will return
-
evalNumber
This method evaluates thisCompareOperatorfor the givenNumberarguments.- Parameters:
arg1- is the first argument.arg2- is the second argument.- Returns:
- the result of the
CompareOperatorapplied to the given arguments. - See Also:
-
toString
- Overrides:
toStringin classEnum<CompareOperator>
-
ofSymbol
This method gets theCompareOperatorfor the givensymbol.- Parameters:
value- is thesymbolof the requestedCompareOperator.- Returns:
- the requested
CompareOperatorornullif no suchCompareOperatorexists.
-