Package org.axonframework.common
Class TypeReference<E>
java.lang.Object
org.axonframework.common.TypeReference<E>
- Type Parameters:
E- The type of the component.
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic <C> TypeReference<C> Constructs aTypeReferencefor the givenclazz.static <C> TypeReference<C> Constructs aTypeReferencefor the giventype.getType()Returns the type of the component represented by thisTypeReference.Returns the class of the type of the component represented by thisTypeReference.inthashCode()booleanisAssignableFrom(TypeReference<?> other) Checks if thisTypeReferenceis assignable from theotherTypeReference.
-
Field Details
-
type
-
-
Constructor Details
-
TypeReference
protected TypeReference()
-
-
Method Details
-
fromClass
Constructs aTypeReferencefor the givenclazz.- Type Parameters:
C- The clazz thisTypeReferencereflects.- Parameters:
clazz- The clazz of theTypeReferenceunder construction.- Returns:
- A new
TypeReferenceinstance of the givenclazz.
-
fromType
Constructs aTypeReferencefor the giventype.- Type Parameters:
C- The type thisTypeReferencereflects.- Parameters:
type- The type of theTypeReferenceunder construction.- Returns:
- A new
TypeReferenceinstance of the giventype.
-
getTypeAsClass
Returns the class of the type of the component represented by thisTypeReference.The class is the erasure of the represented type, following the erasure rules of the Java Language Specification. A
Classerases to itself, aParameterizedTypeto its raw type, aTypeVariableto the erasure of its first bound, and aGenericArrayTypeto an array of the erasure of its component type. Any otherTypeerases toObject.- Returns:
- the class of the component
-
getType
Returns the type of the component represented by thisTypeReference.- Returns:
- The type of the component.
-
isAssignableFrom
Checks if thisTypeReferenceis assignable from theotherTypeReference.It takes generic parameters into account by first checking if the raw types match by means of
Class.isAssignableFrom(Class), subsequently checking for compatibility of generic types by expecting an exact match of the types if any ofthisandotherrepresent a parameterized type.- Parameters:
other- the otherTypeReferenceto compare this to- Returns:
trueif theotherTypeReferenceis assignable from thisTypeReference.
-
equals
-
hashCode
public int hashCode()
-