- 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.ObjectTokenType
represents 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#LONG
is not the same asObjectTokenType<Long>
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkComparable(TokenType type)
Tests whether tokens of the specified type can be compared to tokens of this type.void
dispatchByType(TokenTypeDispatcher dispatcher)
Dispatches processing to the type-appropriate method of the specified dispatcher.boolean
equals(Object o)
int
getEncodedByteSize()
Gets the expected size, in bytes, for tokens of this type.String
getExtendedType()
Returns the "extended type" of this object type.Type[]
getGenericParameters()
Returns the generic type parameters of this object type.ParameterizedType
getParameterizedType()
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.int
hashCode()
boolean
isAbstract()
Indicates whether this type is abstract.boolean
isAssignableFrom(TokenType source)
Indicates whether tokens of the specified type are compatible or implicitly convertible to this type.boolean
isComparable()
Indicates whether the objects described by this token type areComparable
.boolean
isComposite()
Indicates whether this type is a composite type.boolean
isExtendedType()
Returns whether this represents an extended type.boolean
isGeneric()
Indicates whether this type is the generic type.boolean
isParameterizedType()
Returns whether this represents an parameterized type.boolean
isScalar()
Indicates whether this type is a scalar type.String
name()
Gets the printable name of this type.String
toString()
Describes the token type in a human-readable form.
-
-
-
Method Detail
-
name
public String name()
Description copied from interface:TokenType
Gets the printable name of this type.
-
getType
public ObjectTokenType<O> getType()
Description copied from interface:TokenTyped
Gets the type of data tokens handled by the implementor.- Specified by:
getType
in interfaceObjectTyped<O>
- Specified by:
getType
in interfaceScalarTyped
- Specified by:
getType
in 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
Class
object for the tokens described by this type.
-
isComposite
public boolean isComposite()
Description copied from interface:TokenType
Indicates whether this type is a composite type. That is, whether this type describes a structure composed from other types.- Specified by:
isComposite
in interfaceTokenType
- Returns:
- whether this type is composite.
-
isGeneric
public boolean isGeneric()
Description copied from interface:TokenType
Indicates whether this type is the generic type.
-
isScalar
public boolean isScalar()
Description copied from interface:TokenType
Indicates whether this type is a scalar type.
-
isAbstract
public boolean isAbstract()
Description copied from interface:TokenType
Indicates 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:
isAbstract
in 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:
true
if the underlying Java class implements theComparable
interface,false
otherwise.
-
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:TokenType
Indicates whether tokens of the specified type are compatible or implicitly convertible to this type.- Specified by:
isAssignableFrom
in interfaceTokenType
- Parameters:
source
- the token type of the source data- Returns:
true
if the source type can be converted.
-
checkComparable
public void checkComparable(TokenType type)
Description copied from interface:TokenType
Tests 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:
checkComparable
in interfaceTokenType
- Parameters:
type
- the token type of data to compare
-
dispatchByType
public void dispatchByType(TokenTypeDispatcher dispatcher)
Description copied from interface:TokenType
Dispatches 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:
dispatchByType
in interfaceTokenType
- Parameters:
dispatcher
- the class to which to dispatch control
-
getEncodedByteSize
public int getEncodedByteSize()
Description copied from interface:TokenType
Gets 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:
getEncodedByteSize
in interfaceTokenType
- Returns:
- the estimated encoded size of a token of this type.
-
-