Enum Class DataQueryOrder

java.lang.Object
java.lang.Enum<DataQueryOrder>
net.luckperms.api.query.dataorder.DataQueryOrder
All Implemented Interfaces:
Serializable, Comparable<DataQueryOrder>, java.lang.constant.Constable, Comparator<DataType>

public enum DataQueryOrder extends Enum<DataQueryOrder> implements Comparator<DataType>
Represents the order in which to query different DataTypes.

The DataQueryOrder enum simply represents some default implementations of the Comparator required by QueryOptions and the queryInOrder(Comparator, Consumer) or order(Comparator) methods.

Users are free to implement their own comparator. However, be aware that it is possible that more DataTypes may be added in the future. Ideally the Comparator implementations should be able to handle these smoothly.

See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static DataQueryOrder[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DataQueryOrder valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • order

      public static @NonNull List<DataType> order(@NonNull Comparator<? super DataType> comparator)
      Gets a List of all DataTypes, in order of greatest to least, as defined by the comparator.

      Equivalent to calling Arrays.sort(Object[], Comparator) on DataType.values(), but with the comparator reversed.

      Parameters:
      comparator - the comparator
      Returns:
      the ordered data types
    • queryInOrder

      public static void queryInOrder(@NonNull Comparator<? super DataType> comparator, @NonNull Consumer<? super DataType> action)
      Calls the action Consumer for each DataType, in the order defined by the comparator.
      Parameters:
      comparator - the comparator
      action - the action