29
29
import org .springframework .data .mapping .model .PreferredConstructorDiscoverer ;
30
30
import org .springframework .data .projection .ProjectionFactory ;
31
31
import org .springframework .data .projection .ProjectionInformation ;
32
+ import org .springframework .data .util .Lazy ;
32
33
import org .springframework .lang .NonNull ;
33
34
import org .springframework .lang .Nullable ;
34
35
import org .springframework .util .Assert ;
@@ -205,6 +206,8 @@ private static final class ReturnedClass extends ReturnedType {
205
206
private static final Set <Class <?>> VOID_TYPES = new HashSet <>(Arrays .asList (Void .class , void .class ));
206
207
207
208
private final Class <?> type ;
209
+
210
+ private final Lazy <Boolean > isDto ;
208
211
private final List <String > inputProperties ;
209
212
210
213
/**
@@ -222,6 +225,15 @@ public ReturnedClass(Class<?> returnedType, Class<?> domainType) {
222
225
Assert .isTrue (!returnedType .isInterface (), "Returned type must not be an interface" );
223
226
224
227
this .type = returnedType ;
228
+ this .isDto = Lazy .of (() ->
229
+ !Object .class .equals (type ) && //
230
+ !type .isEnum () && //
231
+ !isDomainSubtype () && //
232
+ !isPrimitiveOrWrapper () && //
233
+ !Number .class .isAssignableFrom (type ) && //
234
+ !VOID_TYPES .contains (type ) && //
235
+ !type .getPackage ().getName ().startsWith ("java." )
236
+ );
225
237
this .inputProperties = detectConstructorParameterNames (returnedType );
226
238
}
227
239
@@ -271,13 +283,7 @@ private List<String> detectConstructorParameterNames(Class<?> type) {
271
283
}
272
284
273
285
private boolean isDto () {
274
- return !Object .class .equals (type ) && //
275
- !type .isEnum () && //
276
- !isDomainSubtype () && //
277
- !isPrimitiveOrWrapper () && //
278
- !Number .class .isAssignableFrom (type ) && //
279
- !VOID_TYPES .contains (type ) && //
280
- !type .getPackage ().getName ().startsWith ("java." );
286
+ return isDto .get ();
281
287
}
282
288
283
289
private boolean isDomainSubtype () {
0 commit comments