T
- Value type.public abstract class AttributeType<T>
extends java.lang.Object
AttributeContainer
is an attribute container where
attributes can be stored and AttributeListener
can be set to trigger on value updates.Attributes.newTypeOf(Class)
can be used:
AttributeType <String>
stringType = Attributes.newTypeOf(String.class);
For more complex types an anonymous (or declared) subclasses should be created supplying the
intended value type as the type argument. This is needed so full generic type information can be
retrieved then raw and parameterised types can be differentiated:
AttributeType <Collection<String>>
colStringType = new AttributeType <Collection<String>>
(){};
When using reflection or where type erasure is not possible
Attributes.newUnknownType(Type)
can be used. This will be unique to the type not to
Object.class
.equals(Object)
, hashCode()
and getValueType()
are all
final
.Modifier and Type | Field and Description |
---|---|
protected java.lang.reflect.Type |
valueType
Attribute value type.
|
Constructor and Description |
---|
AttributeType()
Creates a new instance of Attribute type (using generic type information).
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.reflect.Type |
getValueType()
Gets attribute value type.
|
int |
hashCode() |
java.lang.String |
toString() |
public AttributeType() throws java.lang.IllegalStateException
java.lang.IllegalStateException
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public final java.lang.reflect.Type getValueType()
public final int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object