Class 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 as ObjectTokenType<Long>.

    See Also:
    Serialized Form
    • Method Detail

      • name

        public String name()
        Description copied from interface: TokenType
        Gets the printable name of this type.
        Specified by:
        name in interface TokenType
        Returns:
        a user-friendly name for this type
      • 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 interface TokenType
        Returns:
        whether this type is composite.
      • isGeneric

        public boolean isGeneric()
        Description copied from interface: TokenType
        Indicates whether this type is the generic type.
        Specified by:
        isGeneric in interface TokenType
        Returns:
        whether this type is the generic type.
      • isScalar

        public boolean isScalar()
        Description copied from interface: TokenType
        Indicates whether this type is a scalar type.
        Specified by:
        isScalar in interface TokenType
        Returns:
        whether this type is scalar.
      • 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 interface TokenType
        Returns:
        whether this type is abstract.
      • isComparable

        public boolean isComparable()
        Indicates whether the objects described by this token type are Comparable.

        This is similar to checkComparable(TokenType), but returns an answer instead of throwing an error.

        Returns:
        true if the underlying Java class implements the Comparable 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 interface TokenType
        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 interface TokenType
        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 from TypeDispatchedConstructor.
        Specified by:
        dispatchByType in interface TokenType
        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 interface TokenType
        Returns:
        the estimated encoded size of a token of this type.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Describes the token type in a human-readable form.
        Overrides:
        toString in class Object
        Returns:
        a string describing the token type