diff --git a/src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java b/src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java index a88334bce..2b3a61015 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java @@ -85,7 +85,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu IdentifiableType identifiableType = (IdentifiableType) type; - this.idMetadata = new IdMetadata(identifiableType); + this.idMetadata = new IdMetadata<>(identifiableType); this.versionAttribute = findVersionAttribute(identifiableType, metamodel); } @@ -206,7 +206,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu @Override public Iterable getIdAttributeNames() { - List attributeNames = new ArrayList(idMetadata.attributes.size()); + List attributeNames = new ArrayList<>(idMetadata.attributes.size()); for (SingularAttribute attribute : idMetadata.attributes) { attributeNames.add(attribute.getName()); @@ -257,7 +257,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu private @Nullable Class idType; @SuppressWarnings("unchecked") - public IdMetadata(IdentifiableType source) { + IdMetadata(IdentifiableType source) { this.type = source; this.attributes = (Set>) (source.hasSingleIdAttribute() @@ -265,7 +265,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu : source.getIdClassAttributes()); } - public boolean hasSimpleId() { + boolean hasSimpleId() { return attributes.size() == 1; } @@ -304,7 +304,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu return annotation == null ? null : annotation.value(); } - public SingularAttribute getSimpleIdAttribute() { + SingularAttribute getSimpleIdAttribute() { return attributes.iterator().next(); } @@ -383,7 +383,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu if (idPropertyValue != null) { - Class idPropertyValueType = idPropertyValue.getClass(); + Class idPropertyValueType = idPropertyValue.getClass(); if (!jpaMetamodel.isJpaManaged(idPropertyValueType)) { return idPropertyValue; @@ -396,10 +396,10 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu return null; } - private String tryFindSingularIdAttributeNameOrUseFallback(Class idPropertyValueType, + private String tryFindSingularIdAttributeNameOrUseFallback(Class idPropertyValueType, String fallbackIdTypePropertyName) { - ManagedType idPropertyType = metamodel.managedType(idPropertyValueType); + ManagedType idPropertyType = metamodel.managedType(idPropertyValueType); for (SingularAttribute sa : idPropertyType.getSingularAttributes()) { if (sa.isId()) { return sa.getName(); @@ -421,7 +421,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu } try { - ManagedType managedType = this.metamodel.managedType(ProxyUtils.getUserClass(value)); + ManagedType managedType = this.metamodel.managedType(ProxyUtils.getUserClass(value)); return managedType != null && managedType.getPersistenceType() == PersistenceType.ENTITY; } catch (IllegalArgumentException iae) { // no mapped type