Class CommandMeta

  • Direct Known Subclasses:
    SimpleCommandMeta

    public abstract class CommandMeta
    extends java.lang.Object
    Object that is associated with a Command. Command meta should not be mutable, as one fixed instance will be used per command.

    Appropriate use for command meta would be fixed state, such as command descriptions.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  CommandMeta.Key<V>
      A key into the metadata map.
    • Constructor Summary

      Constructors 
      Constructor Description
      CommandMeta()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract <V> @NonNull java.util.Optional<V> get​(@NonNull CommandMeta.Key<V> key)
      Get the value associated with a key.
      abstract @NonNull java.util.Map<@NonNull java.lang.String,​@NonNull java.lang.String> getAll()
      Deprecated.
      for removal since 1.3.0, use getAllValues() instead.
      abstract @NonNull java.util.Map<@NonNull java.lang.String,​?> getAllValues()
      Get a copy of the meta map, without type information.
      abstract <V> @NonNull V getOrDefault​(@NonNull CommandMeta.Key<V> key, @NonNull V defaultValue)
      Get the value if it exists, else return the default value.
      abstract @NonNull java.lang.String getOrDefault​(@NonNull java.lang.String key, @NonNull java.lang.String defaultValue)
      Deprecated.
      for removal since 1.3.0, see typesafe variant at getOrDefault(Key, Object) instead
      abstract @NonNull java.util.Optional<java.lang.String> getValue​(@NonNull java.lang.String key)
      Deprecated.
      for removal since 1.3.0, see typesafe variant at get(Key) instead
      static @NonNull SimpleCommandMeta.Builder simple()
      Create a new simple command meta builder
      @NonNull java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • DESCRIPTION

        public static final CommandMeta.Key<java.lang.String> DESCRIPTION
      • LONG_DESCRIPTION

        public static final CommandMeta.Key<java.lang.String> LONG_DESCRIPTION
    • Constructor Detail

      • CommandMeta

        public CommandMeta()
    • Method Detail

      • simple

        public static @NonNull SimpleCommandMeta.Builder simple()
        Create a new simple command meta builder
        Returns:
        Builder instance
      • toString

        public final @NonNull java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getValue

        @Deprecated
        public abstract @NonNull java.util.Optional<java.lang.String> getValue​(@NonNull java.lang.String key)
        Deprecated.
        for removal since 1.3.0, see typesafe variant at get(Key) instead
        Get the value associated with a key
        Parameters:
        key - Key
        Returns:
        Optional that may contain the associated value
      • getOrDefault

        @Deprecated
        public abstract @NonNull java.lang.String getOrDefault​(@NonNull java.lang.String key,
                                                               @NonNull java.lang.String defaultValue)
        Deprecated.
        for removal since 1.3.0, see typesafe variant at getOrDefault(Key, Object) instead
        Get the value if it exists, else return the default value
        Parameters:
        key - Key
        defaultValue - Default value
        Returns:
        Value, or default value
      • get

        public abstract <V> @NonNull java.util.Optional<V> get​(@NonNull CommandMeta.Key<V> key)
        Get the value associated with a key.
        Type Parameters:
        V - Value type
        Parameters:
        key - Key
        Returns:
        Optional that may contain the associated value
        Since:
        1.3.0
      • getOrDefault

        public abstract <V> @NonNull V getOrDefault​(@NonNull CommandMeta.Key<V> key,
                                                    @NonNull V defaultValue)
        Get the value if it exists, else return the default value.
        Type Parameters:
        V - Value type
        Parameters:
        key - Key
        defaultValue - Default value
        Returns:
        Value, or default value
        Since:
        1.3.0
      • getAll

        @Deprecated
        public abstract @NonNull java.util.Map<@NonNull java.lang.String,​@NonNull java.lang.String> getAll()
        Deprecated.
        for removal since 1.3.0, use getAllValues() instead.
        Get a copy of the meta map
        Returns:
        Copy of meta map
      • getAllValues

        public abstract @NonNull java.util.Map<@NonNull java.lang.String,​?> getAllValues()
        Get a copy of the meta map, without type information.
        Returns:
        Copy of meta map
        Since:
        1.3.0