Skip to main content
summaryrefslogtreecommitdiffstats
blob: a733288c71bbfa9d565f5a0fc7db5d7aee3582ce (plain) (blame)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*******************************************************************************
 * Copyright (c) 2006, 2013 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.jpa.core.context;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.common.core.utility.jdt.TypeBinding;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jpa.core.JpaStructureNode;

/**
 * Context persistent type.
 * <p>
 * Provisional API: This interface is part of an interim API that is still
 * under development and expected to change significantly before reaching
 * stability. It is available at this early stage to solicit feedback from
 * pioneering adopters on the understanding that any code that uses this API
 * will almost certainly be broken (repeatedly) as the API evolves.
 * 
 * @version 3.6
 * @since 2.0
 */
public interface PersistentType
		extends ManagedType, JpaStructureNode, SpecifiedAccessReference {
	
	Class<PersistentType> getManagedTypeType();
	
	
	// ***** mapping *****
	
	/**
	 * String associated with changes to the "mapping" property
	 */
	String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$
	
	/**
	 * Return the persistent type's mapping.
	 * Set the mapping via {@link #setMappingKey(String)}.
	 */
	TypeMapping getMapping();
	
	Transformer<PersistentType, TypeMapping> MAPPING_TRANSFORMER = new MappingTransformer();
	class MappingTransformer
			extends TransformerAdapter<PersistentType, TypeMapping> {
		@Override
		public TypeMapping transform(PersistentType pt) {
			return pt.getMapping();
		}
	}
	
	String getMappingKey();
	
	void setMappingKey(String key);
	
	boolean isMapped();
	
	
	// ********** attributes **********

	/**
	 * Return the persistent type's persistent attributes.
	 */
	ListIterable<? extends PersistentAttribute> getAttributes();
	Transformer<PersistentType, ListIterable<? extends PersistentAttribute>> ATTRIBUTES_TRANSFORMER = new AttributesTransformer();
	class AttributesTransformer
		extends TransformerAdapter<PersistentType, ListIterable<? extends PersistentAttribute>>
	{
		@Override
		public ListIterable<? extends PersistentAttribute> transform(PersistentType type) {
			return type.getAttributes();
		}
	}

	/**
	 * Return the number of the persistent type's persistent attributes.
	 */
	int getAttributesSize();

	/**
	 * Return the names of the persistent type's persistent attributes.
	 */
	Iterable<String> getAttributeNames();

	/**
	 * Return all the persistent attributes in the persistent type's
	 * inheritance hierarchy.
	 */
	Iterable<PersistentAttribute> getAllAttributes();

	/**
	 * Return the names of all the persistent attributes in the
	 * persistent type's hierarchy.
	 */
	Iterable<String> getAllAttributeNames();

	/**
	 * Return the persistent attribute with the specified name,
	 * if it exists locally on the persistent type (as opposed to in its
	 * inheritance hierarchy).
	 */
	PersistentAttribute getAttributeNamed(String attributeName);

	/**
	 * Resolve and return the persistent attribute with the specified name, if it
	 * is distinct and exists within the context of the persistent type.
	 */
	PersistentAttribute resolveAttribute(String attributeName);
	
	/**
	 * Return qualified type name of given attribute within the context of this type.
	 */
	TypeBinding getAttributeTypeBinding(PersistentAttribute attribute);


	// ********** inheritance **********
	
	/**
	 * Return the persistent type of the super type mapping
	 * @see TypeMapping#getSuperTypeMapping()
	 */
	PersistentType getSuperPersistentType();
	
	/**
	 * Return the persistent type's "persistence" inheritance hierarchy,
	 * <em>including</em> the persistent type itself.
	 * @see TypeMapping#getTypeMappingInheritanceHierarchy()
	 */
	Iterable<PersistentType> getInheritanceHierarchy();
	
	/**
	 * Return the persistent type's "persistence" inheritance hierarchy,
	 * <em>excluding</em> the persistent type itself.
	 * @see TypeMapping#getAncesors()
	 */
	Iterable<PersistentType> getAncestors();
	
	
	// ********** misc **********

	/**
	 * Return the persistent type the persistent type overrides.
	 * Typically this is the Java persistent type overridden by a
	 * non-metadata-complete <code>orm.xml</code> persistent type.
	 */
	PersistentType getOverriddenPersistentType();
	Transformer<PersistentType, PersistentType> OVERRIDDEN_PERSISTENT_TYPE_TRANSFORMER = new OverriddenPersistentTypeTransformer();
	class OverriddenPersistentTypeTransformer
		extends TransformerAdapter<PersistentType, PersistentType>
	{
		@Override
		public PersistentType transform(PersistentType persistentType) {
			return persistentType.getOverriddenPersistentType();
		}
	}


	// ********** parent interface **********

	interface Parent
		extends JpaContextModel
	{
		/**
		 * Return the access type that overrides the client persistent type's
		 * access type; <code>null</code> if there is no such access override.
		 */
		AccessType getOverridePersistentTypeAccess();

		/**
		 * Return the client persistent type's default access type;
		 * <code>null</code> if there is no such access default.
		 */
		AccessType getDefaultPersistentTypeAccess();

	}


	// ********** config **********

	/**
	 * Config that can be used to add persistent types to a persistence unit.
	 * @see org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit#addPersistentTypes(Config[], boolean, IProgressMonitor)
	 */
	interface Config {
		String getName();
		String getMappingKey();
	}
}

Back to the top