Class ImmutableCommandDescriptor

java.lang.Object
org.incendo.cloud.annotations.descriptor.ImmutableCommandDescriptor
All Implemented Interfaces:
CommandDescriptor, Descriptor

@Generated("org.immutables.processor.ProxyProcessor") @API(status=STABLE, consumers="org.incendo.cloud.*") public final class ImmutableCommandDescriptor extends Object implements CommandDescriptor
Immutable implementation of CommandDescriptor.

Use the builder to create immutable instances: ImmutableCommandDescriptor.builder(). Use the static factory method to create immutable instances: ImmutableCommandDescriptor.of().

  • Method Details

    • method

      public @NonNull Method method()
      Returns the command method.
      Specified by:
      method in interface CommandDescriptor
      Returns:
      the command method
    • name

      public @NonNull String name()
      Description copied from interface: Descriptor
      Returns the name of the object described by this descriptor.
      Specified by:
      name in interface CommandDescriptor
      Specified by:
      name in interface Descriptor
      Returns:
      The value of the name attribute
    • syntax

      public @NonNull List<SyntaxFragment> syntax()
      Returns an unmodifiable view of the syntax fragments.
      Specified by:
      syntax in interface CommandDescriptor
      Returns:
      the syntax fragments
    • commandToken

      public @NonNull String commandToken()
      Returns the root command name.
      Specified by:
      commandToken in interface CommandDescriptor
      Returns:
      the name of the root command
    • requiredSender

      public @NonNull Class<?> requiredSender()
      Returns the required sender type.
      Specified by:
      requiredSender in interface CommandDescriptor
      Returns:
      the required sender type
    • withMethod

      public final ImmutableCommandDescriptor withMethod(@NonNull Method value)
      Copy the current immutable object by setting a value for the method attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for method
      Returns:
      A modified copy of the this object
    • withName

      public final ImmutableCommandDescriptor withName(@NonNull String value)
      Copy the current immutable object by setting a value for the name attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for name
      Returns:
      A modified copy of the this object
    • withSyntax

      public final ImmutableCommandDescriptor withSyntax(SyntaxFragment... elements)
      Copy the current immutable object with elements that replace the content of syntax.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withSyntax

      public final ImmutableCommandDescriptor withSyntax(Iterable<? extends SyntaxFragment> elements)
      Copy the current immutable object with elements that replace the content of syntax. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of syntax elements to set
      Returns:
      A modified copy of this object
    • withCommandToken

      public final ImmutableCommandDescriptor withCommandToken(@NonNull String value)
      Copy the current immutable object by setting a value for the commandToken attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for commandToken
      Returns:
      A modified copy of the this object
    • withRequiredSender

      public final ImmutableCommandDescriptor withRequiredSender(@NonNull Class<?> value)
      Copy the current immutable object by setting a value for the requiredSender attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for requiredSender
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableCommandDescriptor that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: method, name, syntax, commandToken, requiredSender.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value CommandDescriptor with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static ImmutableCommandDescriptor of(@NonNull Method method, @NonNull String name, @NonNull List<SyntaxFragment> syntax, @NonNull String commandToken, @NonNull Class<?> requiredSender)
      Construct a new immutable CommandDescriptor instance.
      Parameters:
      method - The value for the method attribute
      name - The value for the name attribute
      syntax - The value for the syntax attribute
      commandToken - The value for the commandToken attribute
      requiredSender - The value for the requiredSender attribute
      Returns:
      An immutable CommandDescriptor instance
    • of

      public static ImmutableCommandDescriptor of(@NonNull Method method, @NonNull String name, Iterable<? extends SyntaxFragment> syntax, @NonNull String commandToken, @NonNull Class<?> requiredSender)
      Construct a new immutable CommandDescriptor instance.
      Parameters:
      method - The value for the method attribute
      name - The value for the name attribute
      syntax - The value for the syntax attribute
      commandToken - The value for the commandToken attribute
      requiredSender - The value for the requiredSender attribute
      Returns:
      An immutable CommandDescriptor instance
    • copyOf

      public static ImmutableCommandDescriptor copyOf(CommandDescriptor instance)
      Creates an immutable copy of a CommandDescriptor value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable CommandDescriptor instance
    • builder

      public static ImmutableCommandDescriptor.Builder builder()
      Creates a builder for ImmutableCommandDescriptor.
       ImmutableCommandDescriptor.builder()
          .method(reflect.@org.checkerframework.checker.nullness.qual.NonNull Method) // required method
          .name(@org.checkerframework.checker.nullness.qual.NonNull String) // optional name
          .addSyntax|addAllSyntax(org.incendo.cloud.annotations.SyntaxFragment) // syntax elements
          .commandToken(@org.checkerframework.checker.nullness.qual.NonNull String) // required commandToken
          .requiredSender(@org.checkerframework.checker.nullness.qual.NonNull Class&lt;?&gt;) // required requiredSender
          .build();
       
      Returns:
      A new ImmutableCommandDescriptor builder