Skip to content

Commit b69d810

Browse files
committed
Revert "#67 - Remove target arg from AnnotationDescriptor#ceateUsage forms"
This reverts commit c18eeb9.
1 parent 79ab850 commit b69d810

File tree

5 files changed

+13
-99
lines changed

5 files changed

+13
-99
lines changed

src/main/java/org/hibernate/models/RepeatableAnnotationException.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/org/hibernate/models/internal/dynamic/AbstractAnnotationTarget.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
import java.util.HashMap;
1111
import java.util.Map;
1212

13-
import org.hibernate.models.RepeatableAnnotationException;
1413
import org.hibernate.models.internal.AnnotationTargetSupport;
1514
import org.hibernate.models.spi.AnnotationUsage;
1615
import org.hibernate.models.spi.SourceModelBuildingContext;
1716

18-
import static org.hibernate.models.internal.ModelsLogging.MODELS_LOGGER;
19-
2017
/**
2118
* @author Steve Ebersole
2219
*/
@@ -43,20 +40,17 @@ public void clearAnnotationUsages() {
4340
usageMap.clear();
4441
}
4542

46-
@Override
43+
/**
44+
* Applies the given {@code annotationUsage} to this target.
45+
*
46+
* @todo It is undefined currently what happens if the annotation type is already applied on this target.
47+
*/
4748
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
4849
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
50+
final AnnotationUsage<?> previous = usageMap.put( annotationUsage.getAnnotationType(), annotationUsage );
4951

50-
if ( annotationUsage.getAnnotationDescriptor().isRepeatable() ) {
51-
throw new RepeatableAnnotationException( annotationUsage.getAnnotationDescriptor(), this );
52-
}
53-
54-
final AnnotationUsage<? extends Annotation> previous = getUsageMap().put(
55-
annotationUsage.getAnnotationType(),
56-
annotationUsage
57-
);
58-
if ( previous != null && MODELS_LOGGER.isDebugEnabled() ) {
59-
MODELS_LOGGER.debugf( "AnnotationUsage (%s) was replaced (%s)", annotationUsage, previous );
52+
if ( previous != null ) {
53+
// todo : ignore? log? exception?
6054
}
6155
}
6256

src/main/java/org/hibernate/models/internal/jandex/AbstractAnnotationTarget.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
import java.lang.annotation.Annotation;
1010
import java.util.Map;
1111

12-
import org.hibernate.models.RepeatableAnnotationException;
1312
import org.hibernate.models.internal.AnnotationTargetSupport;
1413
import org.hibernate.models.spi.AnnotationUsage;
1514
import org.hibernate.models.spi.SourceModelBuildingContext;
1615

17-
import static org.hibernate.models.internal.ModelsLogging.MODELS_LOGGER;
18-
1916
/**
2017
* @author Steve Ebersole
2118
*/
@@ -50,18 +47,7 @@ public void clearAnnotationUsages() {
5047
@Override
5148
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
5249
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
53-
54-
if ( annotationUsage.getAnnotationDescriptor().isRepeatable() ) {
55-
throw new RepeatableAnnotationException( annotationUsage.getAnnotationDescriptor(), this );
56-
}
57-
58-
final AnnotationUsage<? extends Annotation> previous = getUsageMap().put(
59-
annotationUsage.getAnnotationType(),
60-
annotationUsage
61-
);
62-
if ( previous != null && MODELS_LOGGER.isDebugEnabled() ) {
63-
MODELS_LOGGER.debugf( "AnnotationUsage (%s) was replaced (%s)", annotationUsage, previous );
64-
}
50+
getUsageMap().put( annotationUsage.getAnnotationType(), annotationUsage );
6551
}
6652

6753
@Override

src/main/java/org/hibernate/models/internal/jdk/AbstractAnnotationTarget.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
import java.util.Map;
1212
import java.util.function.Supplier;
1313

14-
import org.hibernate.models.RepeatableAnnotationException;
1514
import org.hibernate.models.internal.AnnotationTargetSupport;
1615
import org.hibernate.models.spi.AnnotationUsage;
1716
import org.hibernate.models.spi.SourceModelBuildingContext;
1817

19-
import static org.hibernate.models.internal.ModelsLogging.MODELS_LOGGER;
20-
2118
/**
2219
* AnnotationTarget where we know the annotations up front, but
2320
* want to delay processing them until (unless!) they are needed
@@ -68,16 +65,6 @@ public void clearAnnotationUsages() {
6865
@Override
6966
public <X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage) {
7067
assert annotationUsage.getAnnotationDescriptor().getAllowableTargets().contains( getKind() );
71-
if ( annotationUsage.getAnnotationDescriptor().isRepeatable() ) {
72-
throw new RepeatableAnnotationException( annotationUsage.getAnnotationDescriptor(), this );
73-
}
74-
75-
final AnnotationUsage<? extends Annotation> previous = getUsageMap().put(
76-
annotationUsage.getAnnotationType(),
77-
annotationUsage
78-
);
79-
if ( previous != null && MODELS_LOGGER.isDebugEnabled() ) {
80-
MODELS_LOGGER.debugf( "AnnotationUsage (%s) was replaced (%s)", annotationUsage, previous );
81-
}
68+
getUsageMap().put( annotationUsage.getAnnotationType(), annotationUsage );
8269
}
8370
}

src/main/java/org/hibernate/models/spi/MutableAnnotationTarget.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import java.lang.annotation.Annotation;
1010

11-
import org.hibernate.models.RepeatableAnnotationException;
12-
1311
/**
1412
* Extension of AnnotationTarget which allows manipulation of the annotations
1513
*
@@ -24,38 +22,22 @@ public interface MutableAnnotationTarget extends AnnotationTarget {
2422

2523
/**
2624
* Add an annotation usage to this target
27-
*
28-
* @apiNote Expects the {@linkplain AnnotationDescriptor#getRepeatableContainer() container} form instead of
29-
* {@linkplain AnnotationDescriptor#isRepeatable() repeatable} annotations.
30-
*
31-
* @throws RepeatableAnnotationException Indicates a {@linkplain AnnotationDescriptor#isRepeatable() repeatable}
32-
* annotation was passed.
3325
*/
3426
<X extends Annotation> void addAnnotationUsage(AnnotationUsage<X> annotationUsage);
3527

3628
/**
3729
* Applies a usage of the given {@code annotationType} to this target. Will return
3830
* an existing usage, if one, or create a new usage.
39-
*
40-
* @apiNote Expects the {@linkplain AnnotationDescriptor#getRepeatableContainer() container} form instead of
41-
* {@linkplain AnnotationDescriptor#isRepeatable() repeatable} annotations.
42-
*
43-
* @throws RepeatableAnnotationException Indicates a {@linkplain AnnotationDescriptor#isRepeatable() repeatable}
44-
* annotation was passed.
4531
*/
4632
default <A extends Annotation> MutableAnnotationUsage<A> applyAnnotationUsage(
47-
AnnotationDescriptor<A> annotationDescriptor,
33+
AnnotationDescriptor<A> annotationType,
4834
SourceModelBuildingContext buildingContext) {
49-
if ( annotationDescriptor.isRepeatable() ) {
50-
throw new RepeatableAnnotationException( annotationDescriptor, this );
51-
}
52-
53-
final MutableAnnotationUsage<A> existing = (MutableAnnotationUsage<A>) getAnnotationUsage( annotationDescriptor );
35+
final MutableAnnotationUsage<A> existing = (MutableAnnotationUsage<A>) getAnnotationUsage( annotationType );
5436
if ( existing != null ) {
5537
return existing;
5638
}
5739

58-
final MutableAnnotationUsage<A> usage = annotationDescriptor.createUsage( buildingContext );
40+
final MutableAnnotationUsage<A> usage = annotationType.createUsage( buildingContext );
5941
addAnnotationUsage( usage );
6042
return usage;
6143
}

0 commit comments

Comments
 (0)