1 /*
2 * Copyright (c) 2008, 2019 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0 which is available at
6 * http://www.eclipse.org/legal/epl-2.0,
7 * or the Eclipse Distribution License v. 1.0 which is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 *
10 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11 */
12
13 // Contributors:
14 // Linda DeMichiel - 2.1
15 // Linda DeMichiel - 2.0
16
17 package javax.persistence.metamodel;
18
19 /**
20 * Represents an attribute of a Java type.
21 *
22 * @param <X> The represented type that contains the attribute
23 * @param <Y> The type of the represented attribute
24 *
25 * @since 2.0
26 */
27 public interface Attribute<X, Y> {
28
29 public static enum PersistentAttributeType {
30
31 /** Many-to-one association */
32 MANY_TO_ONE,
33
34 /** One-to-one association */
35 ONE_TO_ONE,
36
37 /** Basic attribute */
38 BASIC,
39
40 /** Embeddable class attribute */
41 EMBEDDED,
42
43 /** Many-to-many association */
44 MANY_TO_MANY,
45
46 /** One-to-many association */
47 ONE_TO_MANY,
48
49 /** Element collection */
50 ELEMENT_COLLECTION
51 }
52
53 /**
54 * Return the name of the attribute.
55 * @return name
56 */
57 String getName();
58
59 /**
60 * Return the persistent attribute type for the attribute.
61 * @return persistent attribute type
62 */
63 PersistentAttributeType getPersistentAttributeType();
64
65 /**
66 * Return the managed type representing the type in which
67 * the attribute was declared.
68 * @return declaring type
69 */
70 ManagedType<X> getDeclaringType();
71
72 /**
73 * Return the Java type of the represented attribute.
74 * @return Java type
75 */
76 Class<Y> getJavaType();
77
78 /**
79 * Return the <code>java.lang.reflect.Member</code> for the represented
80 * attribute.
81 * @return corresponding <code>java.lang.reflect.Member</code>
82 */
83 java.lang.reflect.Member getJavaMember();
84
85 /**
86 * Is the attribute an association.
87 * @return boolean indicating whether the attribute
88 * corresponds to an association
89 */
90 boolean isAssociation();
91
92 /**
93 * Is the attribute collection-valued (represents a Collection,
94 * Set, List, or Map).
95 * @return boolean indicating whether the attribute is
96 * collection-valued
97 */
98 boolean isCollection();
99 }
100