T - the value type@NonnullByDefault public interface MetadataKey<T> extends TypeAware<T>
MetadataMap.
Unlike a normal map key, a MetadataKey also holds the type of the values mapped to it.
| Modifier and Type | Method and Description |
|---|---|
T |
cast(Object object)
Attempts to cast the given object to the return type of the key
|
static <T> MetadataKey<T> |
create(String id,
Class<T> clazz)
Creates a MetadataKey with the given id and type
|
static <T> MetadataKey<T> |
create(String id,
com.google.common.reflect.TypeToken<T> type)
Creates a MetadataKey with the given id and type
|
static MetadataKey<Boolean> |
createBooleanKey(String id) |
static MetadataKey<Character> |
createCharacterKey(String id) |
static MetadataKey<Cooldown> |
createCooldownKey(String id) |
static MetadataKey<Double> |
createDoubleKey(String id) |
static MetadataKey<Empty> |
createEmptyKey(String id) |
static MetadataKey<Float> |
createFloatKey(String id) |
static MetadataKey<Integer> |
createIntegerKey(String id) |
static MetadataKey<Long> |
createLongKey(String id) |
static MetadataKey<Short> |
createShortKey(String id) |
static MetadataKey<String> |
createStringKey(String id) |
static MetadataKey<UUID> |
createUuidKey(String id) |
String |
getId()
Gets the id of this key.
|
com.google.common.reflect.TypeToken<T> |
getType()
Get the type of the value mapped to this key
|
static <T> MetadataKey<T> create(String id, com.google.common.reflect.TypeToken<T> type)
T - the value typeid - the id of the keytype - the type of the value mapped to this keystatic <T> MetadataKey<T> create(String id, Class<T> clazz)
T - the value typeid - the id of the keyclazz - the class type of the value mapped to this keystatic MetadataKey<Empty> createEmptyKey(String id)
static MetadataKey<String> createStringKey(String id)
static MetadataKey<Boolean> createBooleanKey(String id)
static MetadataKey<Integer> createIntegerKey(String id)
static MetadataKey<Long> createLongKey(String id)
static MetadataKey<Double> createDoubleKey(String id)
static MetadataKey<Float> createFloatKey(String id)
static MetadataKey<Short> createShortKey(String id)
static MetadataKey<Character> createCharacterKey(String id)
static MetadataKey<Cooldown> createCooldownKey(String id)
static MetadataKey<UUID> createUuidKey(String id)
String getId()
com.google.common.reflect.TypeToken<T> getType()
T cast(Object object) throws ClassCastException
object - the object to be castedClassCastException - if the object cannot be castedCopyright © 2022. All rights reserved.