Class ImmutableFlagDescriptor

java.lang.Object
org.incendo.cloud.annotations.descriptor.ImmutableFlagDescriptor
All Implemented Interfaces:
Descriptor, FlagDescriptor

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

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

  • Method Details

    • parameter

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

      public @NonNull String name()
      Returns the flag name.
      Specified by:
      name in interface Descriptor
      Specified by:
      name in interface FlagDescriptor
      Returns:
      the flag name
    • aliases

      public @NonNull Collection<String> aliases()
      Returns an unmodifiable view of the flag aliases.
      Specified by:
      aliases in interface FlagDescriptor
      Returns:
      the flag aliases
    • 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 FlagDescriptor
      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 FlagDescriptor
      Returns:
      the name of the suggestion provider, or null
    • permission

      public @Nullable Permission permission()
      Returns the permission of the flag.
      Specified by:
      permission in interface FlagDescriptor
      Returns:
      the flag permission, or null
    • description

      public @Nullable Description description()
      Returns the description of the flag.
      Specified by:
      description in interface FlagDescriptor
      Returns:
      the flag description, or null
    • repeatable

      public boolean repeatable()
      Returns whether the flag is repeatable.
      Specified by:
      repeatable in interface FlagDescriptor
      Returns:
      whether the flag is repeatable
    • withParameter

      public final ImmutableFlagDescriptor 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 ImmutableFlagDescriptor 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
    • withAliases

      public final ImmutableFlagDescriptor withAliases(@NonNull Collection<String> value)
      Copy the current immutable object by setting a value for the aliases attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for aliases
      Returns:
      A modified copy of the this object
    • withParserName

      public final ImmutableFlagDescriptor 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 ImmutableFlagDescriptor 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
    • withPermission

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

      public final ImmutableFlagDescriptor 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
    • withRepeatable

      public final ImmutableFlagDescriptor withRepeatable(boolean value)
      Copy the current immutable object by setting a value for the repeatable attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for repeatable
      Returns:
      A modified copy of the this object
    • equals

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

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

      public static ImmutableFlagDescriptor of(@NonNull Parameter parameter, @NonNull String name, @NonNull Collection<String> aliases, @Nullable String parserName, @Nullable String suggestions, @Nullable Permission permission, @Nullable Description description, boolean repeatable)
      Construct a new immutable FlagDescriptor instance.
      Parameters:
      parameter - The value for the parameter attribute
      name - The value for the name attribute
      aliases - The value for the aliases attribute
      parserName - The value for the parserName attribute
      suggestions - The value for the suggestions attribute
      permission - The value for the permission attribute
      description - The value for the description attribute
      repeatable - The value for the repeatable attribute
      Returns:
      An immutable FlagDescriptor instance
    • copyOf

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

      public static ImmutableFlagDescriptor.Builder builder()
      Creates a builder for ImmutableFlagDescriptor.
       ImmutableFlagDescriptor.builder()
          .parameter(reflect.@org.checkerframework.checker.nullness.qual.NonNull Parameter) // required parameter
          .name(@org.checkerframework.checker.nullness.qual.NonNull String) // required name
          .aliases(@org.checkerframework.checker.nullness.qual.NonNull Collection&lt;String&gt;) // required aliases
          .parserName(@org.checkerframework.checker.nullness.qual.Nullable String | null) // nullable parserName
          .suggestions(@org.checkerframework.checker.nullness.qual.Nullable String | null) // nullable suggestions
          .permission(org.incendo.cloud.permission.@org.checkerframework.checker.nullness.qual.Nullable Permission | null) // nullable permission
          .description(org.incendo.cloud.description.@org.checkerframework.checker.nullness.qual.Nullable Description | null) // nullable description
          .repeatable(boolean) // required repeatable
          .build();
       
      Returns:
      A new ImmutableFlagDescriptor builder