Package cloud.commandframework.meta
Interface CommandMeta.Key<V>
-
- Type Parameters:
V
- value type
- All Superinterfaces:
CloudKey<V>
- Enclosing class:
- CommandMeta
public static interface CommandMeta.Key<V> extends CloudKey<V>
A key into the metadata map.- Since:
- 1.3.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @Nullable java.util.function.Function<@NonNull CommandMeta,@Nullable V>
getFallbackDerivation()
Get a function that can be used to compute a fallback based on existing meta.@NonNull java.lang.String
getName()
Get the name of this keydefault @NonNull io.leangen.geantyref.TypeToken<@NonNull V>
getType()
Get the type of the value that this key holds.@NonNull io.leangen.geantyref.TypeToken<V>
getValueType()
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 java.lang.String key)
Create a new metadata key.static <T> @NonNull CommandMeta.Key<T>
of(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull java.lang.String key, @NonNull java.util.function.Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
Create a new metadata key.static <T> @NonNull CommandMeta.Key<T>
of(@NonNull java.lang.Class<T> type, @NonNull java.lang.String key)
Create a new metadata key.static <T> @NonNull CommandMeta.Key<T>
of(@NonNull java.lang.Class<T> type, @NonNull java.lang.String key, @NonNull java.util.function.Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
Create a new metadata key.
-
-
-
Method Detail
-
of
static <T> @NonNull CommandMeta.Key<T> of(@NonNull java.lang.Class<T> type, @NonNull java.lang.String key)
Create a new metadata key.- Type Parameters:
T
- the value type- Parameters:
type
- the value typekey
- 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 java.lang.String key)
Create a new metadata key.- Type Parameters:
T
- the value type- Parameters:
type
- the value typekey
- the name for the key- Returns:
- a new key
-
of
static <T> @NonNull CommandMeta.Key<T> of(@NonNull java.lang.Class<T> type, @NonNull java.lang.String key, @NonNull java.util.function.Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
Create a new metadata key.- Type Parameters:
T
- the value type- Parameters:
type
- the value typekey
- the name for the keyfallbackDerivation
- 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 java.lang.String key, @NonNull java.util.function.Function<@NonNull CommandMeta,@Nullable T> fallbackDerivation)
Create a new metadata key.- Type Parameters:
T
- the value type- Parameters:
type
- the value typekey
- the name for the keyfallbackDerivation
- 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.
-
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 java.lang.String getName()
Get the name of this key
-
getFallbackDerivation
@Nullable java.util.function.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
-
-