17
17
18
18
import java .util .Collection ;
19
19
import java .util .Map ;
20
+ import java .util .Objects ;
20
21
import java .util .Optional ;
21
22
import java .util .concurrent .ConcurrentHashMap ;
22
23
38
39
* @author Oliver Gierke
39
40
* @author Mark Paluch
40
41
* @author Sylvère Richard
42
+ * @author Aref Behboodi
41
43
*/
42
44
public class JpaMetamodel {
43
45
44
46
private static final Map <Metamodel , JpaMetamodel > CACHE = new ConcurrentHashMap <>(4 );
45
47
46
48
private final Metamodel metamodel ;
47
49
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 ;
50
52
51
53
/**
52
54
* Creates a new {@link JpaMetamodel} for the given JPA {@link Metamodel}.
@@ -61,12 +63,12 @@ private JpaMetamodel(Metamodel metamodel) {
61
63
62
64
this .managedTypes = Lazy .of (() -> metamodel .getManagedTypes ().stream () //
63
65
.map (ManagedType ::getJavaType ) //
64
- .filter (it -> it != null ) //
66
+ .filter (Objects :: nonNull ) //
65
67
.collect (StreamUtils .toUnmodifiableSet ()));
66
68
67
69
this .jpaEmbeddables = Lazy .of (() -> metamodel .getEmbeddables ().stream () //
68
70
.map (ManagedType ::getJavaType )
69
- .filter (it -> it != null )
71
+ .filter (Objects :: nonNull )
70
72
.filter (it -> AnnotatedElementUtils .isAnnotated (it , Embeddable .class ))
71
73
.collect (StreamUtils .toUnmodifiableSet ()));
72
74
}
@@ -101,7 +103,7 @@ public boolean isSingleIdAttribute(Class<?> entity, String name, Class<?> attrib
101
103
return metamodel .getEntities ().stream () //
102
104
.filter (it -> entity .equals (it .getJavaType ())) //
103
105
.findFirst () //
104
- .flatMap (it -> getSingularIdAttribute ( it ) ) //
106
+ .flatMap (JpaMetamodel :: getSingularIdAttribute ) //
105
107
.filter (it -> it .getJavaType ().equals (attributeType )) //
106
108
.map (it -> it .getName ().equals (name )) //
107
109
.orElse (false );
0 commit comments