Skip to content

Commit b57b144

Browse files
committed
Minor improvement to DynamicFieldDetails
1 parent 2813172 commit b57b144

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
import java.lang.annotation.Annotation;
1010
import java.lang.reflect.Member;
11-
import java.util.Collection;
12-
import java.util.Map;
1311

1412
import org.hibernate.models.IllegalCastException;
15-
import org.hibernate.models.internal.ModifierUtils;
1613
import org.hibernate.models.spi.AnnotationDescriptor;
1714
import org.hibernate.models.spi.ClassDetails;
1815
import org.hibernate.models.spi.FieldDetails;
16+
import org.hibernate.models.spi.MemberDetails;
1917
import org.hibernate.models.spi.MethodDetails;
2018
import org.hibernate.models.spi.MutableClassDetails;
2119
import org.hibernate.models.spi.MutableMemberDetails;
@@ -25,7 +23,9 @@
2523
import org.hibernate.models.spi.TypeVariableScope;
2624

2725
/**
28-
* FieldDetails which does not necessarily map to a physical Field (dynamic models)
26+
* FieldDetails which does not necessarily map to a physical Field (dynamic models).
27+
*
28+
* @see org.hibernate.models.internal.ModifierUtils#DYNAMIC_ATTRIBUTE_MODIFIERS
2929
*
3030
* @author Steve Ebersole
3131
*/
@@ -38,23 +38,18 @@ public class DynamicFieldDetails extends AbstractAnnotationTarget implements Fie
3838
private final boolean isArray;
3939
private final boolean isPlural;
4040

41-
public DynamicFieldDetails(
42-
String name,
43-
TypeDetails type,
44-
ClassDetails declaringType,
45-
int modifierFlags,
46-
SourceModelBuildingContext buildingContext) {
47-
this(
48-
name,
49-
type,
50-
declaringType,
51-
modifierFlags,
52-
type != null && type.getName().startsWith( "[" ),
53-
type != null && ( type.isImplementor( Collection.class ) || type.isImplementor( Map.class ) ),
54-
buildingContext
55-
);
56-
}
57-
41+
/**
42+
* Constructs a dynamic FieldDetails.
43+
*
44+
* @param name The name of the "field"
45+
* @param type The type of the "field"
46+
* @param declaringType The type on which the "field" is declared
47+
* @param modifierFlags The modifier flags (public, static, etc.) for the "field". Typically, callers should use {@linkplain org.hibernate.models.internal.ModifierUtils#DYNAMIC_ATTRIBUTE_MODIFIERS} when
48+
* defining a field to be used as a {@linkplain MemberDetails#isPersistable() persistable} member.
49+
* @param isArray Whether the "field" is an array
50+
* @param isPlural Whether the "field" is plural
51+
* @param buildingContext Context for the creation (access to useful information).
52+
*/
5853
public DynamicFieldDetails(
5954
String name,
6055
TypeDetails type,
@@ -70,6 +65,8 @@ public DynamicFieldDetails(
7065
this.modifierFlags = modifierFlags;
7166
this.isArray = isArray;
7267
this.isPlural = isPlural;
68+
69+
assert isPersistable();
7370
}
7471

7572
@Override

0 commit comments

Comments
 (0)