From 79e66e7378405f1aefa05e9ab03db3b25562d725 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 24 Apr 2019 14:56:41 +0200 Subject: [PATCH] DATAJPA-1530 - Polishing. Simplified generics. Original pull request: #376. --- .../support/JpaMetamodelEntityInformation.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 f1b869f2d..1573f4886 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); } @@ -201,7 +201,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu */ 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()); @@ -251,7 +251,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() @@ -259,7 +259,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu : source.getIdClassAttributes()); } - public boolean hasSimpleId() { + boolean hasSimpleId() { return attributes.size() == 1; } @@ -298,7 +298,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu return annotation == null ? null : annotation.value(); } - public SingularAttribute getSimpleIdAttribute() { + SingularAttribute getSimpleIdAttribute() { return attributes.iterator().next(); } @@ -376,7 +376,7 @@ public class JpaMetamodelEntityInformation extends JpaEntityInformationSu if (idPropertyValue != null) { - Class idPropertyValueType = idPropertyValue.getClass(); + Class idPropertyValueType = idPropertyValue.getClass(); if (!jpaMetamodel.isJpaManaged(idPropertyValueType)) { return idPropertyValue; @@ -389,10 +389,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(); @@ -414,7 +414,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