Interface CommandMeta.Key<V>

Type Parameters:
V - value type
All Superinterfaces:
CloudKey<V>
Enclosing class:
CommandMeta

@API(status=STABLE, since="1.3.0") public static interface CommandMeta.Key<V> extends CloudKey<V>
A key into the metadata map.
Since:
1.3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Function<@NonNull CommandMeta,@Nullable V>
    Get a function that can be used to compute a fallback based on existing meta.
    @NonNull String
    Get the name of this key
    default @NonNull io.leangen.geantyref.TypeToken<@NonNull V>
    Get the type of the value that this key holds.
    @NonNull io.leangen.geantyref.TypeToken<V>
    Get a representation of the type of value this key holds.
    static <T> @NonNull CommandMeta.Key<T>
    of(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull String key)
    Create a new metadata key.
    static <T> @NonNull CommandMeta.Key<T>
    of(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull String key, @NonNull Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
    Create a new metadata key.
    static <T> @NonNull CommandMeta.Key<T>
    of(@NonNull Class<T> type, @NonNull String key)
    Create a new metadata key.
    static <T> @NonNull CommandMeta.Key<T>
    of(@NonNull Class<T> type, @NonNull String key, @NonNull Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
    Create a new metadata key.
  • Method Details

    • of

      static <T> @NonNull CommandMeta.Key<T> of(@NonNull Class<T> type, @NonNull String key)
      Create a new metadata key.
      Type Parameters:
      T - the value type
      Parameters:
      type - the value type
      key - the name for the key
      Returns:
      a new key
    • of

      static <T> @NonNull CommandMeta.Key<T> of(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull String key)
      Create a new metadata key.
      Type Parameters:
      T - the value type
      Parameters:
      type - the value type
      key - the name for the key
      Returns:
      a new key
    • of

      static <T> @NonNull CommandMeta.Key<T> of(@NonNull Class<T> type, @NonNull String key, @NonNull Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
      Create a new metadata key.
      Type Parameters:
      T - the value type
      Parameters:
      type - the value type
      key - the name for the key
      fallbackDerivation - A function that will be called if no value is present for the key
      Returns:
      a new key
    • of

      static <T> @NonNull CommandMeta.Key<T> of(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull String key, @NonNull Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
      Create a new metadata key.
      Type Parameters:
      T - the value type
      Parameters:
      type - the value type
      key - the name for the key
      fallbackDerivation - A function that will be called if no value is present for the key
      Returns:
      a new key
    • getType

      default @NonNull io.leangen.geantyref.TypeToken<@NonNull V> getType()
      Description copied from interface: CloudKey
      Get the type of the value that this key holds.
      Specified by:
      getType in interface CloudKey<V>
      Returns:
      The type of the key value.
    • getValueType

      @NonNull io.leangen.geantyref.TypeToken<V> getValueType()
      Get a representation of the type of value this key holds.
      Returns:
      the value type
    • getName

      @NonNull String getName()
      Get the name of this key
      Specified by:
      getName in interface CloudKey<V>
      Returns:
      the key type
    • getFallbackDerivation

      @Nullable Function<@NonNull CommandMeta,@Nullable V> getFallbackDerivation()
      Get a function that can be used to compute a fallback based on existing meta.

      This function will only be used if no value is directly for the key.

      Returns:
      the fallback derivation