Record Class EventValueRegistry.Resolution<E extends org.bukkit.event.Event,V>

java.lang.Object
java.lang.Record
org.skriptlang.skript.bukkit.lang.eventvalue.EventValueRegistry.Resolution<E,V>
Type Parameters:
E - the event type
V - the value type
Record Components:
all - all candidates found during resolution
errored - whether the resolution failed due to an abort validation
Enclosing interface:
EventValueRegistry

public static record EventValueRegistry.Resolution<E extends org.bukkit.event.Event,V>(List<EventValue<E extends org.bukkit.event.Event,V>> all, boolean errored) extends Record
Result of a registry resolve operation. May contain multiple candidates or be empty. When errored() is true, at least one candidate failed validation with EventValue.Validation.ABORT and no result should be used.
  • Constructor Details

    • Resolution

      public Resolution(List<EventValue<E,V>> all, boolean errored)
      Creates an instance of a Resolution record class.
      Parameters:
      all - the value for the all record component
      errored - the value for the errored record component
  • Method Details

    • of

      public static <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> of(List<EventValue<E,V>> eventValues)
      Creates a successful resolution from candidates.
      Type Parameters:
      E - the event type
      V - the value type
      Parameters:
      eventValues - the candidates
      Returns:
      a new resolution
    • empty

      public static <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> empty()
      Creates an empty, non-error resolution.
      Type Parameters:
      E - the event type
      V - the value type
      Returns:
      an empty resolution
    • error

      public static <E extends org.bukkit.event.Event, V> EventValueRegistry.Resolution<E,V> error()
      Creates an error resolution (e.g., a candidate failed validation).
      Type Parameters:
      E - the event type
      V - the value type
      Returns:
      an error resolution
    • successful

      public boolean successful()
      Returns:
      true if at least one candidate exists
    • multiple

      public boolean multiple()
      Returns:
      true if multiple candidates are available
    • unique

      public EventValue<E,V> unique()
      Returns:
      the single candidate
      Throws:
      IllegalStateException - if the resolution is not unique
    • uniqueOrNull

      public EventValue<E,V> uniqueOrNull()
      Returns:
      the single candidate or null if not unique
    • uniqueOptional

      public Optional<EventValue<E,V>> uniqueOptional()
      Returns:
      the single candidate as an Optional, empty if not unique
    • any

      public EventValue<E,V> any()
      Returns:
      any candidate
      Throws:
      IllegalStateException - if the resolution is empty
    • anyOrNull

      public EventValue<E,V> anyOrNull()
      Returns:
      any candidate or null if none
    • anyOptional

      public Optional<EventValue<E,V>> anyOptional()
      Returns:
      any candidate as an Optional, empty if none
    • size

      public int size()
      Returns:
      number of candidates contained
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • all

      public List<EventValue<E,V>> all()
      Returns the value of the all record component.
      Returns:
      the value of the all record component
    • errored

      public boolean errored()
      Returns the value of the errored record component.
      Returns:
      the value of the errored record component