Class TypeReference<E>

java.lang.Object
org.axonframework.common.TypeReference<E>
Type Parameters:
E - The type of the component.

public abstract class TypeReference<E> extends Object
Represents a reference to a type of component, allowing for generic types to be specified without casting errors.
Since:
5.0.0
Author:
Mitchell Herrijgers
  • Field Details

    • type

      protected final Type type
  • Constructor Details

    • TypeReference

      protected TypeReference()
  • Method Details

    • fromClass

      public static <C> TypeReference<C> fromClass(@Nonnull Class<C> clazz)
      Constructs a TypeReference for the given clazz.
      Type Parameters:
      C - The clazz this TypeReference reflects.
      Parameters:
      clazz - The clazz of the TypeReference under construction.
      Returns:
      A new TypeReference instance of the given clazz.
    • fromType

      public static <C> TypeReference<C> fromType(@Nonnull Type type)
      Constructs a TypeReference for the given type.
      Type Parameters:
      C - The type this TypeReference reflects.
      Parameters:
      type - The type of the TypeReference under construction.
      Returns:
      A new TypeReference instance of the given type.
    • getTypeAsClass

      @Nonnull public Class<E> getTypeAsClass()
      Returns the class of the type of the component represented by this TypeReference.
      Returns:
      The class of the component.
    • getType

      public Type getType()
      Returns the type of the component represented by this TypeReference.
      Returns:
      The type of the component.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object