Class Comparators
java.lang.Object
org.skriptlang.skript.lang.comparator.Comparators
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T1,
T2> Relation compare
(@Nullable T1 first, @Nullable T2 second) Compares two objects to see if a Relation exists between them.static <T1,
T2> @Nullable Comparator<T1, T2> getComparator
(Class<T1> firstType, Class<T2> secondType) A method for obtaining a Comparator that can compare two objects of 'firstType' and 'secondType'.static <T1,
T2> @Nullable ComparatorInfo<T1, T2> getComparatorInfo
(Class<T1> firstType, Class<T2> secondType) A method for obtaining the info of a Comparator that can compare two objects of 'firstType' and 'secondType'.static @Unmodifiable List<ComparatorInfo<?,
?>> static <T1,
T2> void registerComparator
(Class<T1> firstType, Class<T2> secondType, Comparator<T1, T2> comparator) Registers a new Comparator with Skript's collection of Comparators.
-
Method Details
-
getComparatorInfos
- Returns:
- An unmodifiable list containing all registered
ComparatorInfo
s. Please note that this does not include any special Comparators resolved by Skript during runtime. This method ONLY returns Comparators explicitly registered during registration. Thus, it is recommended to usegetComparator(Class, Class)
if possible.
-
registerComparator
public static <T1,T2> void registerComparator(Class<T1> firstType, Class<T2> secondType, Comparator<T1, T2> comparator) Registers a new Comparator with Skript's collection of Comparators.- Parameters:
firstType
- The first type for comparison.secondType
- The second type for comparison.comparator
- A Comparator for comparing objects of 'firstType' and 'secondType'.
-
compare
Compares two objects to see if a Relation exists between them.- Parameters:
first
- The first object for comparison.second
- The second object for comparison.- Returns:
- The Relation between the two provided objects.
Guaranteed to be
Relation.NOT_EQUAL
if either parameter is null.
-
getComparator
public static <T1,T2> @Nullable Comparator<T1,T2> getComparator(Class<T1> firstType, Class<T2> secondType) A method for obtaining a Comparator that can compare two objects of 'firstType' and 'secondType'. Please note that comparators may convert objects if necessary for comparisons.- Parameters:
firstType
- The first type for comparison.secondType
- The second type for comparison.- Returns:
- A Comparator capable of determine the
Relation
between two objects of 'firstType' and 'secondType'. Will be null if no comparator capable of comparing two objects of 'firstType' and 'secondType' was found.
-
getComparatorInfo
public static <T1,T2> @Nullable ComparatorInfo<T1,T2> getComparatorInfo(Class<T1> firstType, Class<T2> secondType) A method for obtaining the info of a Comparator that can compare two objects of 'firstType' and 'secondType'. Please note that comparators may convert objects if necessary for comparisons.- Parameters:
firstType
- The first type for comparison.secondType
- The second type for comparison.- Returns:
- The info of a Comparator capable of determine the
Relation
between two objects of 'firstType' and 'secondType'. Will be null if no info for comparing two objects of 'firstType' and 'secondType' was found.
-