forked from Blazebit/blaze-persistence
/
ExtendedManagedType.java
103 lines (90 loc) · 3.28 KB
/
ExtendedManagedType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright 2014 - 2018 Blazebit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.blazebit.persistence.spi;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.SingularAttribute;
import java.util.Map;
import java.util.Set;
/**
* This is a wrapper around the JPA {@link javax.persistence.metamodel.ManagedType} that allows additionally efficient access to properties of the metamodel.
*
* @param <X> The Java type represented by this managed type
* @author Christian Beikov
* @since 1.2.0
*/
public interface ExtendedManagedType<X> {
/**
* Returns the underlying managed type.
*
* @return The managed type
*/
public ManagedType<X> getType();
/**
* Returns an entity type and path that owns this embeddable type via a singular attribute or null if there is none.
*
* @return An entity type and path that owns this embeddable type via a singular attribute or null if there is none
* @since 1.3.0
*/
public Map.Entry<EntityType<?>, String> getEmbeddableSingularOwner();
/**
* Returns an entity type and path that owns this embeddable type via a plural attribute or null if there is none.
*
* @return An entity type and path that owns this embeddable type via a plural attribute or null if there is none
* @since 1.3.0
*/
public Map.Entry<EntityType<?>, String> getEmbeddablePluralOwner();
/**
* Returns whether the type has a cascading delete cycle.
*
* @return True if it has a cascading delete cycle, false otherwise
*/
public boolean hasCascadingDeleteCycle();
/**
* Returns the id attribute if it has one, otherwise null.
*
* @return The id attribute or null
*/
public SingularAttribute<X, ?> getIdAttribute();
/**
* Returns the id attributes or an empty set if it doesn't have an id.
*
* @return The id attributes
* @since 1.3.0
*/
public Set<SingularAttribute<X, ?>> getIdAttributes();
/**
* Returns the extended attributes of the managed type.
*
* @return The extended attributes
*/
public Map<String, ExtendedAttribute<X, ?>> getAttributes();
/**
* Returns the owned extended attributes of the managed type.
*
* @return The owned extended attributes
* @since 1.3.0
*/
public Map<String, ExtendedAttribute<X, ?>> getOwnedAttributes();
/**
* Returns the extended attribute of the managed type for the given attribute name.
*
* @param attributeName The attribute name
* @return The extended attributes
* @throws IllegalArgumentException Is thrown when the attribute doesn't exist
*/
public ExtendedAttribute<X, ?> getAttribute(String attributeName);
}