add uniform API for annotation access to AnnotationTarget #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
AnnotationTarget
interface gains these methods:boolean hasAnnotation(DotName)
AnnotationInstance annotation(DotName)
Collection<AnnotationInstance> annotations(DotName)
Collection<AnnotationInstance> annotationsWithRepeatable(DotName, IndexView)
Collection<AnnotationInstance> annotations()
boolean hasDeclaredAnnotation(DotName)
AnnotationInstance declaredAnnotation(DotName)
Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName, IndexView)
Collection<AnnotationInstance> declaredAnnotations()
Many classes that implement
AnnotationTarget
already had a lotof these methods. First major change here is that now, all
implementations of
AnnotationTarget
do. A second major changeis the addition of methods with "declared" in the name: those only
look at annotations present on the annotation target in question
and not on nested annotation targets. Finally, a third major change
is that the collection-returning methods now always return immutable
collections.
The
Type
class is expanded to provide a similar set of methods:boolean hasAnnotation(DotName)
AnnotationInstance annotation(DotName)
Collection<AnnotationInstance> annotationsWithRepeatable(DotName, IndexView)
Collection<AnnotationInstance> annotations()
The
MethodParameterInfo
class is a first-class citizen now.It is possible to navigate from
MethodInfo
to all parametersrepresented as
MethodParameterInfo
, plusMethodParameterInfo
exposes the parameter type.
MethodInfo
also exposes the numberof parameters directly as
parametersCount()
.All this happens only on the API level, internal representation
of anything doesn't change. There are two breaking changes:
ClassInfo.annotations()
method no longer returns aMap
,it returns a
List
now; the original method is still availableas
annotationsMap()
MethodInfo.parameters()
method no longer returns aList<Type>
,it returns a
List<MethodParameterInfo>
now; the original methodis still available as
parameterTypes()
Additionally, all the
ClassInfo.classAnnotation*
methods aredeprecated in favor of
declaredAnnotation*
.Resolves #131.