public static class DataTypeImpl.Definition extends Object implements CQLDataType
Definition class provides a data type definition for a CQL
data type.| Constructor and Description |
|---|
Definition(DataType type,
DataType... arguments)
Instantiates a new
Definition object. |
Definition(DataType type,
List<CQLDataType> arguments)
Instantiates a new
Definition object. |
Definition(List<CQLDataType> types)
Instantiates a new
Definition object. |
| Modifier and Type | Method and Description |
|---|---|
<T,PT> Object |
decode(Object val,
Persisted persisted,
Persister<T,PT> persister,
String fname)
Decodes the specified value using the given persister based on this
definition.
|
<T,PT> Object |
encode(Object val,
Persisted persisted,
Persister<T,PT> persister,
String fname)
Encodes the specified value using the given persister based on this
definition.
|
<T,PT> Object |
encodeElement(Object val,
Persisted persisted,
Persister<T,PT> persister,
String fname)
Encodes the specified element value using the given persister based on this
definition.
|
List<CQLDataType> |
getArgumentTypes() |
DataDecoder<?> |
getDecoder(Class<?> clazz)
Gets a decoder for this data type to decode to the specified class.
|
DataDecoder<?> |
getDecoder(Field field,
boolean mandatory)
Gets a decoder for this data type to decode to the specified field.
|
CQLDataType |
getElementType() |
CQLDataType |
getFirstArgumentType() |
CQLDataType |
getMainType() |
boolean |
isAlterableTo(CQLDataType to) |
boolean |
isCollection() |
boolean |
isUserDefined() |
String |
name() |
String |
toCQL() |
String |
toString() |
java.util.stream.Stream<UDTClassInfoImpl<?>> |
udts()
Gets all user-defined types this definition is dependent on.
|
public Definition(DataType type, DataType... arguments)
Definition object.type - the non-null data type for this definitionarguments - the non-null list of arguments' data types
if the type represents a collection (may be empty)public Definition(DataType type, List<CQLDataType> arguments)
Definition object.type - the non-null data type for this definitionarguments - the non-null list of arguments' data types
if the type represents a collection (may be empty)public Definition(List<CQLDataType> types)
Definition object.types - the non-null list of data types for this
definition (the first one correspond to the data type and the
remaining are the argument data types)public String name()
name in interface CQLDataTypeCQLDataType.name()public boolean isCollection()
isCollection in interface CQLDataTypeCQLDataType.isCollection()public boolean isUserDefined()
isUserDefined in interface CQLDataTypeCQLDataType.isUserDefined()public CQLDataType getMainType()
getMainType in interface CQLDataTypeCQLDataType.getMainType()public CQLDataType getElementType()
getElementType in interface CQLDataTypeCQLDataType.getElementType()public List<CQLDataType> getArgumentTypes()
getArgumentTypes in interface CQLDataTypeCQLDataType.getArgumentTypes()public CQLDataType getFirstArgumentType()
getFirstArgumentType in interface CQLDataTypeCQLDataType.getFirstArgumentType()public boolean isAlterableTo(CQLDataType to)
isAlterableTo in interface CQLDataTypeCQLDataType.isAlterableTo(org.helenus.driver.persistence.CQLDataType)public DataDecoder<?> getDecoder(Field field, boolean mandatory)
field - the field to decode to its declared typemandatory - if the field is mandatory or represents a primary keyNullPointerException - if field is nullIllegalArgumentException - if the combination of field and data types
is not supportedpublic DataDecoder<?> getDecoder(Class<?> clazz)
clazz - the collection class to decode to its declared super typeNullPointerException - if clazz is nullIllegalArgumentException - if the combination of class and data types
is not supportedIllegalStateException - if this definition is not representing a
collectionpublic <T,PT> Object encode(Object val, Persisted persisted, Persister<T,PT> persister, String fname) throws IOException
T - the decoded typePT - the persisted typeval - the value to be encodedpersisted - the persisted annotation for the persisterpersister - the persister to usefname - the non-null field namenull if the value
was null to start with or no encoding was requiredIOException - if an encoding error occursClassCastException - if this definition represents a collection
and the value cannot be type casted to the expected collection
type or the encoded value cannot be type casted to the persisted
classpublic <T,PT> Object encodeElement(Object val, Persisted persisted, Persister<T,PT> persister, String fname) throws IOException
T - the decoded typePT - the persisted typeval - the element value to be encodedpersisted - the persisted annotation for the persisterpersister - the persister to usefname - the non-null field namenull if the value
was null to start with or no encoding was requiredIOException - if an encoding error occurspublic <T,PT> Object decode(Object val, Persisted persisted, Persister<T,PT> persister, String fname) throws IOException
T - the decoded typePT - the persisted typeval - the value to be encodedpersisted - the persisted annotation for the persisterpersister - the persister to usefname - the non-null field namenull if the value
was null to start with or no decoding was requiredIOException - if an encoding error occursClassCastException - if this definition represents a collection
and the value cannot be type casted to the expected collection
type or again the value to decode cannot be type casted to the
persisted classpublic String toCQL()
toCQL in interface CQLDataTypeCQLDataType.toCQL()public java.util.stream.Stream<UDTClassInfoImpl<?>> udts()
public String toString()
toString in class ObjectObject.toString()Copyright (C) 2015-2015 The Helenus Driver Project Authors.