Class ImmutableArgumentDescriptor

java.lang.Object
org.incendo.cloud.annotations.descriptor.ImmutableArgumentDescriptor
All Implemented Interfaces:
ArgumentDescriptor, Descriptor

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

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

  • Method Details

    • parameter

      public @NonNull Parameter parameter()
      Returns the parameter.
      Specified by:
      parameter in interface ArgumentDescriptor
      Returns:
      the parameter
    • name

      public @NonNull String name()
      Returns the argument name
      Specified by:
      name in interface ArgumentDescriptor
      Specified by:
      name in interface Descriptor
      Returns:
      the argument name
    • parserName

      public @Nullable String parserName()
      Returns the name of the parser to use. If null the default parser for the parameter type will be used.
      Specified by:
      parserName in interface ArgumentDescriptor
      Returns:
      the parser name, or null
    • suggestions

      public @Nullable String suggestions()
      Returns the name of the suggestion provider to use. If the string is null, the default provider for the argument parser will be used. Otherwise, the ParserRegistry instance in the CommandManager will be queried for a matching suggestion provider.

      For this to work, the suggestion needs to be registered in the parser registry. To do this, use ParserRegistry.registerSuggestionProvider(String, SuggestionProvider). The registry instance can be retrieved using CommandManager.parserRegistry().

      Specified by:
      suggestions in interface ArgumentDescriptor
      Returns:
      the name of the suggestion provider, or null
    • defaultValue

      public @Nullable DefaultValue<?,?> defaultValue()
      Returns the default value.
      Specified by:
      defaultValue in interface ArgumentDescriptor
      Returns:
      the default value, or null
    • description

      public @Nullable Description description()
      Returns the description of the argument.
      Specified by:
      description in interface ArgumentDescriptor
      Returns:
      the argument description, or null
    • withParameter

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

      public final ImmutableArgumentDescriptor 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
    • withParserName

      public final ImmutableArgumentDescriptor withParserName(@Nullable String value)
      Copy the current immutable object by setting a value for the parserName attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parserName (can be null)
      Returns:
      A modified copy of the this object
    • withSuggestions

      public final ImmutableArgumentDescriptor withSuggestions(@Nullable String value)
      Copy the current immutable object by setting a value for the suggestions attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for suggestions (can be null)
      Returns:
      A modified copy of the this object
    • withDefaultValue

      public final ImmutableArgumentDescriptor withDefaultValue(@Nullable DefaultValue<?,?> value)
      Copy the current immutable object by setting a value for the defaultValue attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for defaultValue (can be null)
      Returns:
      A modified copy of the this object
    • withDescription

      public final ImmutableArgumentDescriptor withDescription(@Nullable Description value)
      Copy the current immutable object by setting a value for the description attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for description (can be null)
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableArgumentDescriptor 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: parameter, name, parserName, suggestions, defaultValue, description.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static ImmutableArgumentDescriptor of(@NonNull Parameter parameter, @NonNull String name, @Nullable String parserName, @Nullable String suggestions, @Nullable DefaultValue<?,?> defaultValue, @Nullable Description description)
      Construct a new immutable ArgumentDescriptor instance.
      Parameters:
      parameter - The value for the parameter attribute
      name - The value for the name attribute
      parserName - The value for the parserName attribute
      suggestions - The value for the suggestions attribute
      defaultValue - The value for the defaultValue attribute
      description - The value for the description attribute
      Returns:
      An immutable ArgumentDescriptor instance
    • copyOf

      public static ImmutableArgumentDescriptor copyOf(ArgumentDescriptor instance)
      Creates an immutable copy of a ArgumentDescriptor 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 ArgumentDescriptor instance
    • builder

      public static ImmutableArgumentDescriptor.Builder builder()
      Creates a builder for ImmutableArgumentDescriptor.
       ImmutableArgumentDescriptor.builder()
          .parameter(reflect.@org.checkerframework.checker.nullness.qual.NonNull Parameter) // required parameter
          .name(@org.checkerframework.checker.nullness.qual.NonNull String) // required name
          .parserName(@org.checkerframework.checker.nullness.qual.Nullable String | null) // nullable parserName
          .suggestions(@org.checkerframework.checker.nullness.qual.Nullable String | null) // nullable suggestions
          .defaultValue(org.incendo.cloud.component.@org.checkerframework.checker.nullness.qual.Nullable DefaultValue&lt;?, ?&gt; | null) // nullable defaultValue
          .description(org.incendo.cloud.description.@org.checkerframework.checker.nullness.qual.Nullable Description | null) // nullable description
          .build();
       
      Returns:
      A new ImmutableArgumentDescriptor builder