Class TypeToken<T>

java.lang.Object
de.espirit.common.lang.TypeToken<T>
Direct Known Subclasses:
OperationType

public abstract class TypeToken<T> extends Object
Abstract type token implementation, click on Use-link above for further reading. This class is not intended to be subclassed by API-Users.
Since:
4.2.405
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Error thrown, if the sub-type does not give a proper parametrization.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    cast(Object object)
    Cast the given object to the underlying type of this token.
    final boolean
    Generic equal implementation for type tokens that evaluates to equal, if the given object is an instance of the direct supertype of the questioned instance, plus having equal generic types.
    final Type
    Gets the token's type.
    boolean
    Test the given object to be an instance of the underlying (raw) type of this token.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TypeToken

      public TypeToken()
  • Method Details

    • getType

      public final Type getType()
      Gets the token's type.
      Returns:
      The type of this token.
      Since:
      4.2.405
    • cast

      public T cast(Object object)
      Cast the given object to the underlying type of this token. Will throw ClassCastException, if the given object is not assignable to this token's raw type, but will not check for the generic type.
      Parameters:
      object - The object to be cast.
      Returns:
      The cast instance.
      Since:
      4.2.405
    • isInstance

      public boolean isInstance(Object object)
      Test the given object to be an instance of the underlying (raw) type of this token.
      Parameters:
      object - The object to be tested.
      Returns:
      true, iff the object is a matching instance.
      Since:
      4.2.405
    • equals

      public final boolean equals(Object obj)
      Generic equal implementation for type tokens that evaluates to equal, if the given object is an instance of the direct supertype of the questioned instance, plus having equal generic types.

      The implementation is optimized to return early where the generic type of the compared type token differs. If they are the same then a relative costly check for the equality of the superclassis performed.

      Overrides:
      equals in class Object
      Parameters:
      obj - The object given for comparison.
      Returns:
      true, iff both instances have the same supertype and equal generic types.
      Since:
      4.2.405