Package org.jboss.jandex
Class EquivalenceKey
- java.lang.Object
-
- org.jboss.jandex.EquivalenceKey
-
- Direct Known Subclasses:
EquivalenceKey.DeclarationEquivalenceKey
,EquivalenceKey.TypeEquivalenceKey
public abstract class EquivalenceKey extends java.lang.Object
Establishes a notion of equivalence of Jandex objects. Two Jandex objects are equivalent if and only if they denote the same Java declaration or type, without taking into account any annotations. The prime use case is to assist with building annotation overlays on top of Jandex, where it is common to have multiple Jandex objects with different annotations, but otherwise equivalent.In contrast, the common Jandex classes such as
ClassInfo
,MethodInfo
orFieldInfo
either don't provide equality at all (and hence can only be compared by identity) or provide strict equality, which includes presence or absence of annotations and comparison of their members, as well as other details.An instance of this class, also called an equivalence key, provides 3 fundamental operations, corresponding to the 3 common methods all Java classes have:
equals()
: when two Jandex objects are equivalent, their equivalence keys are equalhashCode()
: consistent withequals()
described abovetoString()
: human readable representation of the equivalence key; format of the value is not guaranteed and may change without notice
EquivalenceKey
DeclarationEquivalenceKey
ClassEquivalenceKey
MethodEquivalenceKey
MethodParameterEquivalenceKey
FieldEquivalenceKey
RecordComponentEquivalenceKey
TypeEquivalenceKey
ArrayTypeEquivalenceKey
ClassTypeEquivalenceKey
ParameterizedTypeEquivalenceKey
PrimitiveTypeEquivalenceKey
TypeVariableEquivalenceKey
TypeVariableReferenceEquivalenceKey
UnresolvedTypeVariableEquivalenceKey
VoidTypeEquivalenceKey
WildcardTypeEquivalenceKey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EquivalenceKey.ArrayTypeEquivalenceKey
static class
EquivalenceKey.ClassEquivalenceKey
static class
EquivalenceKey.ClassTypeEquivalenceKey
static class
EquivalenceKey.DeclarationEquivalenceKey
static class
EquivalenceKey.FieldEquivalenceKey
static class
EquivalenceKey.MethodEquivalenceKey
static class
EquivalenceKey.MethodParameterEquivalenceKey
static class
EquivalenceKey.ParameterizedTypeEquivalenceKey
static class
EquivalenceKey.PrimitiveTypeEquivalenceKey
static class
EquivalenceKey.RecordComponentEquivalenceKey
static class
EquivalenceKey.TypeEquivalenceKey
static class
EquivalenceKey.TypeVariableEquivalenceKey
static class
EquivalenceKey.TypeVariableReferenceEquivalenceKey
static class
EquivalenceKey.UnresolvedTypeVariableEquivalenceKey
static class
EquivalenceKey.VoidTypeEquivalenceKey
static class
EquivalenceKey.WildcardTypeEquivalenceKey
-
Constructor Summary
Constructors Modifier Constructor Description private
EquivalenceKey()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EquivalenceKey
of(AnnotationTarget annotationTarget)
Returns an equivalence key for givenannotation target
.static EquivalenceKey.ClassEquivalenceKey
of(ClassInfo clazz)
Returns an equivalence key for given class.static EquivalenceKey.DeclarationEquivalenceKey
of(Declaration declaration)
Returns an equivalence key for givendeclaration
.static EquivalenceKey.FieldEquivalenceKey
of(FieldInfo field)
Returns an equivalence key for given field.static EquivalenceKey.MethodEquivalenceKey
of(MethodInfo method)
Returns an equivalence key for given method.static EquivalenceKey.MethodParameterEquivalenceKey
of(MethodParameterInfo parameter)
Returns an equivalence key for given method parameter.static EquivalenceKey.RecordComponentEquivalenceKey
of(RecordComponentInfo recordComponent)
Returns an equivalence key for given record component.static EquivalenceKey.TypeEquivalenceKey
of(Type type)
Returns an equivalence key for given type.private static EquivalenceKey.TypeEquivalenceKey[]
of(Type[] types)
static EquivalenceKey.TypeEquivalenceKey
of(TypeTarget typeTarget)
Returns an equivalence key for given type annotation target.private static java.lang.String
toStringWhereClause(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
(package private) java.lang.String
toStringWithWhere(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
-
-
Method Detail
-
of
public static EquivalenceKey of(AnnotationTarget annotationTarget)
Returns an equivalence key for givenannotation target
.- Parameters:
annotationTarget
- the annotation target, may benull
- Returns:
- equvalence key for given annotation target, only
null
ifannotationTarget == null
-
of
public static EquivalenceKey.DeclarationEquivalenceKey of(Declaration declaration)
Returns an equivalence key for givendeclaration
.- Parameters:
declaration
- the declaration, may benull
- Returns:
- equvalence key for given declaration, only
null
ifdeclaration == null
- Since:
- 3.1.0
-
of
public static EquivalenceKey.ClassEquivalenceKey of(ClassInfo clazz)
Returns an equivalence key for given class.- Parameters:
clazz
- the class, may benull
- Returns:
- equvalence key for given class, only
null
ifclazz == null
-
of
public static EquivalenceKey.MethodEquivalenceKey of(MethodInfo method)
Returns an equivalence key for given method.- Parameters:
method
- the method, may benull
- Returns:
- equvalence key for given method, only
null
ifmethod == null
-
of
public static EquivalenceKey.MethodParameterEquivalenceKey of(MethodParameterInfo parameter)
Returns an equivalence key for given method parameter.- Parameters:
parameter
- the method parameter, may benull
- Returns:
- equvalence key for given method parameter, only
null
ifparameter == null
-
of
public static EquivalenceKey.FieldEquivalenceKey of(FieldInfo field)
Returns an equivalence key for given field.- Parameters:
field
- the field, may benull
- Returns:
- equvalence key for given field, only
null
iffield == null
-
of
public static EquivalenceKey.RecordComponentEquivalenceKey of(RecordComponentInfo recordComponent)
Returns an equivalence key for given record component.- Parameters:
recordComponent
- the record component, may benull
- Returns:
- equvalence key for given record component, only
null
ifrecordComponent == null
-
of
public static EquivalenceKey.TypeEquivalenceKey of(TypeTarget typeTarget)
Returns an equivalence key for given type annotation target. It is the equivalence key of the annotated type.- Parameters:
typeTarget
- the type target, may benull
- Returns:
- equvalence key for given type target, only
null
iftypeTarget == null
-
of
public static EquivalenceKey.TypeEquivalenceKey of(Type type)
Returns an equivalence key for given type.- Parameters:
type
- the type, may benull
- Returns:
- equvalence key for given type, only
null
iftype == null
-
of
private static EquivalenceKey.TypeEquivalenceKey[] of(Type[] types)
-
toStringWithWhere
java.lang.String toStringWithWhere(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
toStringWhereClause
private static java.lang.String toStringWhereClause(java.util.Set<EquivalenceKey.TypeVariableEquivalenceKey> typeVariables)
-
-