@Immutable
public final class TypedName<T>
extends java.lang.Object
implements java.io.Serializable
An association of a type with a name. This is used for type-safe (or at least type-suggested) access to entity attributes, and allows declarations of attribute names to also contain the type of data that will be stored in the specified attribute.
When used consistently, they allow for type-safe access to entity attribute data.
Typed names are unique objects, so they can be safely compared with ==
.
Modifier and Type | Method and Description |
---|---|
static <T> TypedName<T> |
create(java.lang.String name,
java.lang.Class<T> type)
Create a typed name object.
|
static TypedName<?> |
create(java.lang.String name,
java.lang.String typeName)
Create an typed name from a name and type name.
|
static <T> TypedName<T> |
create(java.lang.String name,
TypeToken<T> type)
Create a typed name object.
|
com.fasterxml.jackson.databind.JavaType |
getJacksonType()
Get a Jackson
JavaType for this typed name. |
java.lang.String |
getName()
Get the underlying name.
|
java.lang.Class<? super T> |
getRawType()
Get the raw type (class).
|
TypeToken<T> |
getType()
Get the type.
|
T |
parseString(java.lang.String value)
Parse a string containing this attribute’s value.
|
java.lang.String |
toString() |
@Nonnull public java.lang.String getName()
Get the underlying name.
String.intern()
).@Nonnull public TypeToken<T> getType()
Get the type. This will never be a primitive type class; primitive classes are always normalized to their wrapper classes (e.g. long.class
becomes Long.class
).
@Nonnull public java.lang.Class<? super T> getRawType()
Get the raw type (class). This will never be a primitive type class; primitive classes are always normalized to their wrapper classes (e.g. long.class
becomes Long.class
).
public com.fasterxml.jackson.databind.JavaType getJacksonType()
Get a Jackson JavaType
for this typed name.
public T parseString(java.lang.String value)
Parse a string containing this attribute’s value.
public java.lang.String toString()
toString
in class java.lang.Object
@Nonnull public static <T> TypedName<T> create(java.lang.String name, java.lang.Class<T> type)
Create a typed name object.
name
- The name.type
- The type.@Nonnull public static <T> TypedName<T> create(java.lang.String name, TypeToken<T> type)
Create a typed name object.
name
- The name.type
- The type.public static TypedName<?> create(java.lang.String name, java.lang.String typeName)
Create an typed name from a name and type name.
name
- The name.typeName
- The type name.java.lang.IllegalArgumentException
- if typeName
is not a valid type name.