Skip to content

Commit

Permalink
#58 - Assert annotation is legal when adding to target
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Apr 4, 2024
1 parent 7d55df9 commit 7492b52
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void clearAnnotationUsages() {
* @todo It is undefined currently what happens if the annotation type is already applied on this target.
*/
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
final AnnotationUsage<?> previous = usageMap.put( annotationUsage.getAnnotationType(), annotationUsage );

if ( previous != null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void clearAnnotationUsages() {

@Override
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
getUsageMap().put( annotationUsage.getAnnotationType(), annotationUsage );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void clearAnnotationUsages() {

@Override
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
getUsageMap().put( annotationUsage.getAnnotationType(), annotationUsage );
}
}

0 comments on commit 7492b52

Please sign in to comment.