@Immutable public final class TypedName<T> extends Object implements 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.
Modifier and Type | Method and Description |
---|---|
static <T> TypedName<T> |
create(String name,
Class<T> type)
Create a typed name object.
|
static TypedName<?> |
create(String name,
String typeName)
Create an typed name from a name and type name.
|
boolean |
equals(Object o) |
String |
getName()
Get the underlying name.
|
Class<T> |
getType()
Get the type.
|
int |
hashCode() |
T |
parseString(String value)
Parse a string containing this attribute’s value.
|
String |
toString() |
@Nonnull public Class<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
).
public T parseString(String value)
Parse a string containing this attribute’s value.
@Nonnull public static <T> TypedName<T> create(String name, Class<T> type)
Create a typed name object.
name
- The name.type
- The type.public static TypedName<?> create(String name, String typeName)
Create an typed name from a name and type name.
name
- The name.typeName
- The type name.IllegalArgumentException
- if typeName
is not a valid type name.