Browse Source

Polishing.

See #3160
pull/3166/head
Mark Paluch 1 year ago
parent
commit
737502c4e4
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 22
      src/main/java/org/springframework/data/repository/query/ReturnedType.java

22
src/main/java/org/springframework/data/repository/query/ReturnedType.java

@ -29,7 +29,6 @@ import org.springframework.data.mapping.PreferredConstructor; @@ -29,7 +29,6 @@ import org.springframework.data.mapping.PreferredConstructor;
import org.springframework.data.mapping.model.PreferredConstructorDiscoverer;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.projection.ProjectionInformation;
import org.springframework.data.util.Lazy;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@ -227,8 +226,8 @@ public abstract class ReturnedType { @@ -227,8 +226,8 @@ public abstract class ReturnedType {
private static final Set<Class<?>> VOID_TYPES = new HashSet<>(Arrays.asList(Void.class, void.class));
private final Lazy<Boolean> isDto;
private final Class<?> type;
private final boolean isDto;
private final List<String> inputProperties;
/**
@ -246,15 +245,14 @@ public abstract class ReturnedType { @@ -246,15 +245,14 @@ public abstract class ReturnedType {
Assert.isTrue(!returnedType.isInterface(), "Returned type must not be an interface");
this.type = returnedType;
this.isDto = Lazy.of(() ->
!Object.class.equals(type) && //
!type.isEnum() && //
!isDomainSubtype() && //
!isPrimitiveOrWrapper() && //
!Number.class.isAssignableFrom(type) && //
!VOID_TYPES.contains(type) && //
!type.getPackage().getName().startsWith("java.")
);
this.isDto = !Object.class.equals(type) && //
!type.isEnum() && //
!isDomainSubtype() && //
!isPrimitiveOrWrapper() && //
!Number.class.isAssignableFrom(type) && //
!VOID_TYPES.contains(type) && //
!type.getPackage().getName().startsWith("java.");
this.inputProperties = detectConstructorParameterNames(returnedType);
}
@ -306,7 +304,7 @@ public abstract class ReturnedType { @@ -306,7 +304,7 @@ public abstract class ReturnedType {
}
private boolean isDto() {
return isDto.get();
return isDto;
}
private boolean isDomainSubtype() {

Loading…
Cancel
Save