21
21
import java .util .Collection ;
22
22
import java .util .Collections ;
23
23
import java .util .LinkedHashSet ;
24
- import java .util .List ;
25
24
import java .util .Map ;
26
25
import java .util .Optional ;
27
26
import java .util .Set ;
28
27
import java .util .function .Supplier ;
29
28
30
- import org .springframework .core .GenericTypeResolver ;
31
29
import org .springframework .data .mapping .Association ;
32
30
import org .springframework .data .mapping .PersistentEntity ;
33
31
import org .springframework .data .mapping .PersistentProperty ;
34
32
import org .springframework .data .util .Lazy ;
33
+ import org .springframework .data .util .NullableWrapperConverters ;
35
34
import org .springframework .data .util .ReflectionUtils ;
36
35
import org .springframework .data .util .TypeInformation ;
37
36
import org .springframework .lang .Nullable ;
@@ -94,18 +93,17 @@ public AbstractPersistentProperty(Property property, PersistentEntity<?, P> owne
94
93
this .usePropertyAccess = Lazy .of (() -> owner .getType ().isInterface () || CAUSE_FIELD .equals (getField ()));
95
94
96
95
this .isAssociation = Lazy .of (() -> ASSOCIATION_TYPE != null && ASSOCIATION_TYPE .isAssignableFrom (rawType ));
97
- this .associationTargetType = ASSOCIATION_TYPE == null
98
- ? Lazy .empty ()
99
- : Lazy .of (() -> Optional .of (getTypeInformation ())
100
- .map (it -> it .getSuperTypeInformation (ASSOCIATION_TYPE ))
101
- .map (TypeInformation ::getComponentType )
96
+ this .associationTargetType = ASSOCIATION_TYPE == null //
97
+ ? Lazy .empty () //
98
+ : Lazy .of (() -> Optional .of (getTypeInformation ()) //
99
+ .map (it -> it .getSuperTypeInformation (ASSOCIATION_TYPE )) //
100
+ .map (TypeInformation ::getComponentType ) //
102
101
.orElse (null ));
103
102
104
103
this .entityTypeInformation = Lazy .of (() -> Optional .ofNullable (getAssociationOrActualType ())
105
104
.filter (it -> !simpleTypeHolder .isSimpleType (it .getType ())) //
106
105
.filter (it -> !it .isCollectionLike ()) //
107
- .filter (it -> !it .isMap ())
108
- .orElse (null ));
106
+ .filter (it -> !it .isMap ()).orElse (null ));
109
107
110
108
this .getter = property .getGetter ().orElse (null );
111
109
this .setter = property .getSetter ().orElse (null );
@@ -121,32 +119,34 @@ public AbstractPersistentProperty(Property property, PersistentEntity<?, P> owne
121
119
this .entityTypes = Lazy .of (() -> collectEntityTypes (simpleTypeHolder , information , new LinkedHashSet <>()));
122
120
}
123
121
124
- protected Set <TypeInformation <?>> collectEntityTypes (SimpleTypeHolder simpleTypeHolder , @ Nullable TypeInformation <?> typeInformation , Set <TypeInformation <?>> entityTypes ) {
122
+ protected Set <TypeInformation <?>> collectEntityTypes (SimpleTypeHolder simpleTypeHolder ,
123
+ @ Nullable TypeInformation <?> typeInformation , Set <TypeInformation <?>> entityTypes ) {
125
124
126
- if (typeInformation == null || entityTypes .contains (typeInformation ) || simpleTypeHolder .isSimpleType (typeInformation .getType ())) {
125
+ if (typeInformation == null || entityTypes .contains (typeInformation )
126
+ || simpleTypeHolder .isSimpleType (typeInformation .getType ())) {
127
127
return entityTypes ;
128
128
}
129
129
130
- if (typeInformation .isMap ()) {
130
+ if (typeInformation .isMap ()) {
131
131
132
132
collectEntityTypes (simpleTypeHolder , typeInformation .getComponentType (), entityTypes );
133
133
collectEntityTypes (simpleTypeHolder , typeInformation .getMapValueType (), entityTypes );
134
134
return entityTypes ;
135
135
}
136
136
137
- if (typeInformation .isCollectionLike ()) {
137
+ if (typeInformation .isCollectionLike ()) {
138
138
139
139
collectEntityTypes (simpleTypeHolder , typeInformation .getComponentType (), entityTypes );
140
140
return entityTypes ;
141
141
}
142
142
143
- if ( typeInformation .isNullableWrapper ( )) {
143
+ if ( NullableWrapperConverters . supports ( typeInformation .getType () )) {
144
144
145
145
collectEntityTypes (simpleTypeHolder , typeInformation .getActualType (), entityTypes );
146
146
return entityTypes ;
147
147
}
148
148
149
- if (ASSOCIATION_TYPE != null && ASSOCIATION_TYPE .isAssignableFrom (typeInformation .getType ())) {
149
+ if (ASSOCIATION_TYPE != null && ASSOCIATION_TYPE .isAssignableFrom (typeInformation .getType ())) {
150
150
151
151
entityTypes .add (getAssociationOrActualType ());
152
152
return entityTypes ;
@@ -210,7 +210,7 @@ public TypeInformation<?> getTypeInformation() {
210
210
@ Override
211
211
public Iterable <? extends TypeInformation <?>> getPersistentEntityTypes () {
212
212
213
- if (isMap () || isCollectionLike ()) {
213
+ if (isMap () || isCollectionLike ()) {
214
214
return entityTypes .get ();
215
215
}
216
216
0 commit comments