Package elki.data.type
Class SimpleTypeInformation<T>
- java.lang.Object
-
- elki.data.type.SimpleTypeInformation<T>
-
- Type Parameters:
T
- Java type we represent.
- All Implemented Interfaces:
TypeInformation
- Direct Known Subclasses:
VectorTypeInformation
public class SimpleTypeInformation<T> extends java.lang.Object implements TypeInformation
Class wrapping a particular data type.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<? super T>
cls
The restriction class we represent.private java.lang.String
label
Type label.private ByteBufferSerializer<? super T>
serializer
Type serializer.
-
Constructor Summary
Constructors Constructor Description SimpleTypeInformation(java.lang.Class<? super T> cls)
Constructor.SimpleTypeInformation(java.lang.Class<? super T> cls, ByteBufferSerializer<? super T> serializer)
Constructor.SimpleTypeInformation(java.lang.Class<? super T> cls, java.lang.String label)
Constructor.SimpleTypeInformation(java.lang.Class<? super T> cls, java.lang.String label, ByteBufferSerializer<? super T> serializer)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
cast(java.lang.Object other)
Cast the object to type T (actually to the given restriction class!).java.lang.String
getLabel()
Get the type label.java.lang.Class<? super T>
getRestrictionClass()
Get the raw restriction class.ByteBufferSerializer<? super T>
getSerializer()
Get the serializer for this type.boolean
isAssignableFrom(java.lang.Object other)
Test whether this type is assignable from a given object instance.boolean
isAssignableFromType(TypeInformation type)
Test whether this type is assignable from another type.void
setSerializer(ByteBufferSerializer<? super T> serializer)
Set the serializer for this type.java.lang.String
toString()
-
-
-
Field Detail
-
cls
private java.lang.Class<? super T> cls
The restriction class we represent.
-
label
private java.lang.String label
Type label.
-
serializer
private ByteBufferSerializer<? super T> serializer
Type serializer.
-
-
Constructor Detail
-
SimpleTypeInformation
public SimpleTypeInformation(java.lang.Class<? super T> cls)
Constructor.- Parameters:
cls
- restriction class
-
SimpleTypeInformation
public SimpleTypeInformation(java.lang.Class<? super T> cls, java.lang.String label)
Constructor.- Parameters:
cls
- restriction classlabel
- type label
-
SimpleTypeInformation
public SimpleTypeInformation(java.lang.Class<? super T> cls, ByteBufferSerializer<? super T> serializer)
Constructor.- Parameters:
cls
- restriction classserializer
- Serializer
-
SimpleTypeInformation
public SimpleTypeInformation(java.lang.Class<? super T> cls, java.lang.String label, ByteBufferSerializer<? super T> serializer)
Constructor.- Parameters:
cls
- restriction classlabel
- type labelserializer
- Serializer
-
-
Method Detail
-
getRestrictionClass
public final java.lang.Class<? super T> getRestrictionClass()
Get the raw restriction class.- Returns:
- Restriction class
-
isAssignableFromType
public boolean isAssignableFromType(TypeInformation type)
Description copied from interface:TypeInformation
Test whether this type is assignable from another type.- Specified by:
isAssignableFromType
in interfaceTypeInformation
- Parameters:
type
- Other type- Returns:
- true when the other type is accepted as subtype.
-
isAssignableFrom
public boolean isAssignableFrom(java.lang.Object other)
Description copied from interface:TypeInformation
Test whether this type is assignable from a given object instance.- Specified by:
isAssignableFrom
in interfaceTypeInformation
- Parameters:
other
- Other object- Returns:
- true when the other type is an acceptable instance.
-
cast
public T cast(java.lang.Object other)
Cast the object to type T (actually to the given restriction class!).- Parameters:
other
- Object to cast.- Returns:
- Instance
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLabel
public java.lang.String getLabel()
Get the type label.- Returns:
- Label
-
getSerializer
public ByteBufferSerializer<? super T> getSerializer()
Get the serializer for this type.- Returns:
- Type serializer
-
setSerializer
public void setSerializer(ByteBufferSerializer<? super T> serializer)
Set the serializer for this type.- Parameters:
serializer
- Serializer to use
-
-