- java.lang.Object
-
- com.pervasive.datarush.types.ObjectTokenType<O>
-
- Type Parameters:
O- The underlying Java class of the tokens represented by this type.
- All Implemented Interfaces:
ObjectTyped<O>,ScalarTokenType,ScalarTyped,TokenType,TokenTyped,Serializable
public class ObjectTokenType<O> extends Object implements ScalarTokenType, ObjectTyped<O>
A description of a scalar data type for a Java class. DataRush provides an number of built-in types which are implemented in an efficient, type-specific way. However, it is possible to extend token types permit tokens represented by any arbitrary Java class.ObjectTokenTyperepresents these token types.To define a token type for a given class, use
TokenTypeConstant#OBJECT(Class)to obtain an instance describing the type.Note that while the built-in types do have corresponding Java classes, these types are not equivalent to the matching
ObjectTokenType. That is,TokenTypeConstant#LONGis not the same asObjectTokenType<Long>.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckComparable(TokenType type)Tests whether tokens of the specified type can be compared to tokens of this type.voiddispatchByType(TokenTypeDispatcher dispatcher)Dispatches processing to the type-appropriate method of the specified dispatcher.booleanequals(Object o)intgetEncodedByteSize()Gets the expected size, in bytes, for tokens of this type.StringgetExtendedType()Returns the "extended type" of this object type.Type[]getGenericParameters()Returns the generic type parameters of this object type.ParameterizedTypegetParameterizedType()Returns the "parameterized type" of this object type which includes information about the generic parameter types.Class<O>getTokenClass()Returns the Java class of tokens having this token type.ObjectTokenType<O>getType()Gets the type of data tokens handled by the implementor.inthashCode()booleanisAbstract()Indicates whether this type is abstract.booleanisAssignableFrom(TokenType source)Indicates whether tokens of the specified type are compatible or implicitly convertible to this type.booleanisComparable()Indicates whether the objects described by this token type areComparable.booleanisComposite()Indicates whether this type is a composite type.booleanisExtendedType()Returns whether this represents an extended type.booleanisGeneric()Indicates whether this type is the generic type.booleanisParameterizedType()Returns whether this represents an parameterized type.booleanisScalar()Indicates whether this type is a scalar type.Stringname()Gets the printable name of this type.StringtoString()Describes the token type in a human-readable form.
-
-
-
Method Detail
-
name
public String name()
Description copied from interface:TokenTypeGets the printable name of this type.
-
getType
public ObjectTokenType<O> getType()
Description copied from interface:TokenTypedGets the type of data tokens handled by the implementor.- Specified by:
getTypein interfaceObjectTyped<O>- Specified by:
getTypein interfaceScalarTyped- Specified by:
getTypein interfaceTokenTyped- Returns:
- the type of tokens associated with the class.
-
getExtendedType
public String getExtendedType()
Returns the "extended type" of this object type. An extended type may be used to represent types that do not correspond to java classes. Will return null if this represents a java type. Note that even extended types must have an associated java type which is a base class.- Returns:
- the "extended type" of this object type
-
isExtendedType
public boolean isExtendedType()
Returns whether this represents an extended type.- Returns:
- whether this represents an extended type.
-
getTokenClass
public Class<O> getTokenClass()
Returns the Java class of tokens having this token type.- Returns:
- the
Classobject for the tokens described by this type.
-
isComposite
public boolean isComposite()
Description copied from interface:TokenTypeIndicates whether this type is a composite type. That is, whether this type describes a structure composed from other types.- Specified by:
isCompositein interfaceTokenType- Returns:
- whether this type is composite.
-
isGeneric
public boolean isGeneric()
Description copied from interface:TokenTypeIndicates whether this type is the generic type.
-
isScalar
public boolean isScalar()
Description copied from interface:TokenTypeIndicates whether this type is a scalar type.
-
isAbstract
public boolean isAbstract()
Description copied from interface:TokenTypeIndicates whether this type is abstract. Scalar types are never abstract. The generic type always is. Composite types are abstract if either: they are comprised of no fields or they contain an abstract type.- Specified by:
isAbstractin interfaceTokenType- Returns:
- whether this type is abstract.
-
isComparable
public boolean isComparable()
Indicates whether the objects described by this token type areComparable.This is similar to
checkComparable(TokenType), but returns an answer instead of throwing an error.- Returns:
trueif the underlying Java class implements theComparableinterface,falseotherwise.
-
getGenericParameters
public Type[] getGenericParameters()
Returns the generic type parameters of this object type.- Returns:
- the generic type parameters of this object type
-
getParameterizedType
public ParameterizedType getParameterizedType()
Returns the "parameterized type" of this object type which includes information about the generic parameter types.- Returns:
- the "parameterized type" of this object type
-
isParameterizedType
public boolean isParameterizedType()
Returns whether this represents an parameterized type.- Returns:
- whether this represents an parameterized type.
-
isAssignableFrom
public boolean isAssignableFrom(TokenType source)
Description copied from interface:TokenTypeIndicates whether tokens of the specified type are compatible or implicitly convertible to this type.- Specified by:
isAssignableFromin interfaceTokenType- Parameters:
source- the token type of the source data- Returns:
trueif the source type can be converted.
-
checkComparable
public void checkComparable(TokenType type)
Description copied from interface:TokenTypeTests whether tokens of the specified type can be compared to tokens of this type. For two types to be comparable, at least one type must be implicitly convertible to the other.- Specified by:
checkComparablein interfaceTokenType- Parameters:
type- the token type of data to compare
-
dispatchByType
public void dispatchByType(TokenTypeDispatcher dispatcher)
Description copied from interface:TokenTypeDispatches processing to the type-appropriate method of the specified dispatcher. This is used in generic code to perform type-specific actions based on other input; a rather common case is object construction, where the dispatcher is usually derived fromTypeDispatchedConstructor.- Specified by:
dispatchByTypein interfaceTokenType- Parameters:
dispatcher- the class to which to dispatch control
-
getEncodedByteSize
public int getEncodedByteSize()
Description copied from interface:TokenTypeGets the expected size, in bytes, for tokens of this type. For variable sized types, such as binary data or strings, this is a guess of the average size.- Specified by:
getEncodedByteSizein interfaceTokenType- Returns:
- the estimated encoded size of a token of this type.
-
-