Package manifold.ext.rt.api
Interface ComparableUsing<T>
-
- All Superinterfaces:
Comparable<T>
public interface ComparableUsing<T> extends Comparable<T>
Implement thisComparableextension to enable relational operators directly on your type. Normally you only need to implementComparable#compareTo(T), the remaining method in this interface have default implementations suitable for most use-cases. However, if necessary you can override behavior for individual relational operators by overriding#compareToUsing(T,Operator). Note implementing this interface automatically overloads==and!=. The default behavior delegates tocompareTo(), but you can easily change the behavior by overridingequalityMode(), seeComparableUsing.EqualityModeoptions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classComparableUsing.EqualityModeThe mode indicating the method used to implement==and!=operators.static classComparableUsing.OperatorRelational operators to implement
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default booleancompareToUsing(T that, ComparableUsing.Operator op)Comparethistothatusingop.default ComparableUsing.EqualityModeequalityMode()The method used to handle==and!=-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
compareToUsing
default boolean compareToUsing(T that, ComparableUsing.Operator op)
Comparethistothatusingop. Calls to this method are generated for usage of>, >=, <, and <=. IfequalityMode()returnsCompareTo, calls to this method are also generated for==and!=. Normally you do not need to implement this method because it delegates to your type's#compareTo(T)implementation. However, you can override this default implementation to customize behavior.
-
equalityMode
default ComparableUsing.EqualityMode equalityMode()
The method used to handle==and!=
-
-