Record Class Invocation

java.lang.Object
java.lang.Record
dev.sympho.modular_commands.api.command.Invocation
Record Components:
chain - The invocation chain, the sequence of keys that forms the invocation.
All Implemented Interfaces:
Iterable<String>

public record Invocation(List<String> chain) extends Record implements Iterable<String>
An invocation of a command. That is, a sequence of keys (names) that (possibly) map to a command in the system.
Since:
1.0
Version:
1.0
  • Field Details

    • EMPTY

      public static final Invocation EMPTY
      The empty invocation.
  • Constructor Details

    • Invocation

      @Pure public Invocation(List<String> chain)
      Constructs an invocation determined by the given chain.
      Parameters:
      chain - The invocation chain.
  • Method Details

    • child

      @Pure public Invocation child(String command)
      Determines the invocation formed by adding the given command name to this invocation.
      Parameters:
      command - The child command to invoke.
      Returns:
      The invocation of the child command.
    • parent

      @Pure public Invocation parent()
      Determines the parent invocation of this chain.
      Returns:
      The invocation of the parent command.
    • of

      @Pure public static Invocation of(List<String> commands)
      Constructs an invocation from the given sequence of command names.
      Parameters:
      commands - The command names.
      Returns:
      The constructed invocation.
    • of

      @Pure public static Invocation of(String... commands)
      Constructs an invocation from the given sequence of command names.
      Parameters:
      commands - The command names.
      Returns:
      The constructed invocation.
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • spliterator

      public Spliterator<String> spliterator()
      Specified by:
      spliterator in interface Iterable<String>
    • stream

      @SideEffectFree public Stream<String> stream()
      Obtains a stream over the invocation elements.
      Returns:
      The stream.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • chain

      public List<String> chain()
      Returns the value of the chain record component.
      Returns:
      the value of the chain record component