Interface ITypeRef<T>

  • Type Parameters:
    T - The (static) type of this type reference.
    All Superinterfaces:
    IDynamicType<T>
    All Known Implementing Classes:
    ATypeRef, ATypeRefIdentity, ITypeRef.ClassTypeRef
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ITypeRef<T>
    extends IDynamicType<T>
    Captures the relationship between the static type T and the runtime type getType(). Due to the lack of proper generic support in the Java reflection library, this interface is currently not statically type safe. As such implementors are responsible for type safety.
    • Method Detail

      • of

        static <T> ITypeRef<T> of​(Class<T> type)
        Construct an instance of ITypeRef for a Java Class. This is most useful for non-parameterized classes.
        Type Parameters:
        T - The (static) type of the resulting type reference.
        Parameters:
        type - The class to create a reference to.
        Returns:
        An instance of ITypeRef whose getType() returns type.
      • getErasedType

        default Class<T> getErasedType()
      • getType

        Type getType()
        Get the dynamic (runtime) type of T.
        Returns:
        The dynamic (runtime) type of T.
      • isAssignableFrom

        default @com.g2forge.alexandria.annotations.note.Note(type=com.g2forge.alexandria.annotations.note.NoteType.TODO, value="Implementation is neither general to all dynamic types, nor generic-safe") boolean isAssignableFrom​(IDynamicType<?> type)
        Specified by:
        isAssignableFrom in interface IDynamicType<T>
      • isInstance

        default @com.g2forge.alexandria.annotations.note.Note(type=com.g2forge.alexandria.annotations.note.NoteType.TODO, value="Take generics into account when determining instanceOf, right now it\'s only checked erased type") boolean isInstance​(Object value)
        Specified by:
        isInstance in interface IDynamicType<T>