Skip to content

Commit 124391d

Browse files
committed
#48 - Build DynamicAnnotationUsage with SourceModelContext instead of SourceModelBuildingContext
1 parent bf75ee2 commit 124391d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.hibernate.models.spi.AnnotationTarget;
2222
import org.hibernate.models.spi.AttributeDescriptor;
2323
import org.hibernate.models.spi.MutableAnnotationUsage;
24-
import org.hibernate.models.spi.SourceModelBuildingContext;
24+
import org.hibernate.models.spi.SourceModelContext;
2525

2626
/**
2727
* AnnotationUsage built dynamically (for dynamic models, XML mappings, etc.)
@@ -36,14 +36,14 @@ public class DynamicAnnotationUsage<A extends Annotation> implements MutableAnno
3636

3737
public DynamicAnnotationUsage(
3838
AnnotationDescriptor<A> annotationDescriptor,
39-
SourceModelBuildingContext context) {
39+
SourceModelContext context) {
4040
this( annotationDescriptor, null, context );
4141
}
4242

4343
public DynamicAnnotationUsage(
4444
AnnotationDescriptor<A> annotationDescriptor,
4545
AnnotationTarget target,
46-
SourceModelBuildingContext context) {
46+
SourceModelContext context) {
4747
this.annotationDescriptor = annotationDescriptor;
4848
this.target = target;
4949

@@ -128,7 +128,7 @@ public <V> V setAttributeValue(String name, V value) {
128128
private static <A extends Annotation> Map<String, Object> extractBaselineValues(
129129
AnnotationDescriptor<A> annotationDescriptor,
130130
AnnotationTarget target,
131-
SourceModelBuildingContext context) {
131+
SourceModelContext context) {
132132
final HashMap<String, Object> values = new HashMap<>();
133133
for ( AttributeDescriptor<?> attribute : annotationDescriptor.getAttributes() ) {
134134
values.put( attribute.getName(), getDefaultValue( attribute, target, context ) );
@@ -139,7 +139,7 @@ private static <A extends Annotation> Map<String, Object> extractBaselineValues(
139139
private static Object getDefaultValue(
140140
AttributeDescriptor<?> attribute,
141141
AnnotationTarget target,
142-
SourceModelBuildingContext context) {
142+
SourceModelContext context) {
143143
final Object defaultValue = attribute.getAttributeMethod().getDefaultValue();
144144
Object annotation = wrapValue( defaultValue, target, context );
145145
if ( annotation != null ) {
@@ -148,7 +148,7 @@ private static Object getDefaultValue(
148148
return defaultValue;
149149
}
150150

151-
private static Object wrapValue(Object value, AnnotationTarget target, SourceModelBuildingContext context) {
151+
private static Object wrapValue(Object value, AnnotationTarget target, SourceModelContext context) {
152152
if ( value instanceof Annotation annotation ) {
153153
try {
154154
return extractDynamicAnnotationUsage( annotation, target, context );
@@ -169,7 +169,7 @@ else if ( value.getClass() == Class.class ) {
169169
return value;
170170
}
171171

172-
private static <E> List getList(Object defaultValue, AnnotationTarget target, SourceModelBuildingContext context) {
172+
private static <E> List getList(Object defaultValue, AnnotationTarget target, SourceModelContext context) {
173173
List result = new ArrayList<>();
174174
E[] d = (E[]) defaultValue;
175175
for ( E e : d ) {
@@ -181,7 +181,7 @@ private static <E> List getList(Object defaultValue, AnnotationTarget target, So
181181
private static DynamicAnnotationUsage<?> extractDynamicAnnotationUsage(
182182
Annotation annotation,
183183
AnnotationTarget target,
184-
SourceModelBuildingContext context) throws InvocationTargetException, IllegalAccessException {
184+
SourceModelContext context) throws InvocationTargetException, IllegalAccessException {
185185
final Class<? extends Annotation> annotationType = annotation.annotationType();
186186
final AnnotationDescriptor<?> descriptor = context.getAnnotationDescriptorRegistry()
187187
.getDescriptor( annotationType );

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.hibernate.models.spi.TypeDetails;
2020
import org.hibernate.models.spi.TypeVariableDetails;
2121

22+
import static org.hibernate.models.internal.util.StringHelper.isEmpty;
23+
2224
/**
2325
* ClassDetails which does not necessarily map to a physical Class (dynamic models)
2426
*
@@ -123,7 +125,7 @@ public List<TypeVariableDetails> getTypeParameters() {
123125

124126
@Override
125127
public boolean isImplementor(Class<?> checkType) {
126-
return checkType.isAssignableFrom( javaType );
128+
return !isEmpty( className ) && checkType.isAssignableFrom( javaType );
127129
}
128130

129131
@Override

0 commit comments

Comments
 (0)