Class FlagContext


  • public final class FlagContext
    extends java.lang.Object
    Flag value mappings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.Object FLAG_PRESENCE_VALUE
      Dummy object stored as a flag value when the flag has no associated parser
    • Method Summary

      Modifier and Type Method Description
      void addPresenceFlag​(@NonNull CommandFlag<?> flag)
      Indicate that a presence flag was supplied
      <T> void addValueFlag​(@NonNull CommandFlag<T> flag, @NonNull T value)
      Store a value associated with a value flag
      static @NonNull FlagContext create()
      Create a new flag context instance
      <T> @Nullable T getValue​(@NonNull java.lang.String name, @Nullable T defaultValue)
      Get a flag value
      boolean isPresent​(@NonNull java.lang.String flag)
      Check whether or not a flag is present.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FLAG_PRESENCE_VALUE

        public static final java.lang.Object FLAG_PRESENCE_VALUE
        Dummy object stored as a flag value when the flag has no associated parser
    • Method Detail

      • create

        public static @NonNull FlagContext create()
        Create a new flag context instance
        Returns:
        Constructed instance
      • addPresenceFlag

        public void addPresenceFlag​(@NonNull CommandFlag<?> flag)
        Indicate that a presence flag was supplied
        Parameters:
        flag - Flag instance
      • addValueFlag

        public <T> void addValueFlag​(@NonNull CommandFlag<T> flag,
                                     @NonNull T value)
        Store a value associated with a value flag
        Type Parameters:
        T - Value type
        Parameters:
        flag - Value flag
        value - Flag value
      • isPresent

        public boolean isPresent​(@NonNull java.lang.String flag)
        Check whether or not a flag is present. This will return false for all value flags.
        Parameters:
        flag - Flag name
        Returns:
        true if the flag is presence and the flag is a presence flag, else false
      • getValue

        public <T> @Nullable T getValue​(@NonNull java.lang.String name,
                                        @Nullable T defaultValue)
        Get a flag value
        Type Parameters:
        T - Value type
        Parameters:
        name - Flag name
        defaultValue - Default value
        Returns:
        Stored value, or the supplied default value