1717
1818import java .util .Collection ;
1919import java .util .Map ;
20+ import java .util .Objects ;
2021import java .util .Optional ;
2122import java .util .concurrent .ConcurrentHashMap ;
2223
3839 * @author Oliver Gierke
3940 * @author Mark Paluch
4041 * @author Sylvère Richard
42+ * @author Aref Behboodi
4143 */
4244public class JpaMetamodel {
4345
4446 private static final Map <Metamodel , JpaMetamodel > CACHE = new ConcurrentHashMap <>(4 );
4547
4648 private final Metamodel metamodel ;
4749
48- private Lazy <Collection <Class <?>>> managedTypes ;
49- private Lazy <Collection <Class <?>>> jpaEmbeddables ;
50+ private final Lazy <Collection <Class <?>>> managedTypes ;
51+ private final Lazy <Collection <Class <?>>> jpaEmbeddables ;
5052
5153 /**
5254 * Creates a new {@link JpaMetamodel} for the given JPA {@link Metamodel}.
@@ -61,12 +63,12 @@ private JpaMetamodel(Metamodel metamodel) {
6163
6264 this .managedTypes = Lazy .of (() -> metamodel .getManagedTypes ().stream () //
6365 .map (ManagedType ::getJavaType ) //
64- .filter (it -> it != null ) //
66+ .filter (Objects :: nonNull ) //
6567 .collect (StreamUtils .toUnmodifiableSet ()));
6668
6769 this .jpaEmbeddables = Lazy .of (() -> metamodel .getEmbeddables ().stream () //
6870 .map (ManagedType ::getJavaType )
69- .filter (it -> it != null )
71+ .filter (Objects :: nonNull )
7072 .filter (it -> AnnotatedElementUtils .isAnnotated (it , Embeddable .class ))
7173 .collect (StreamUtils .toUnmodifiableSet ()));
7274 }
@@ -101,7 +103,7 @@ public boolean isSingleIdAttribute(Class<?> entity, String name, Class<?> attrib
101103 return metamodel .getEntities ().stream () //
102104 .filter (it -> entity .equals (it .getJavaType ())) //
103105 .findFirst () //
104- .flatMap (it -> getSingularIdAttribute ( it ) ) //
106+ .flatMap (JpaMetamodel :: getSingularIdAttribute ) //
105107 .filter (it -> it .getJavaType ().equals (attributeType )) //
106108 .map (it -> it .getName ().equals (name )) //
107109 .orElse (false );
0 commit comments