1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.model.jdo.caching;
19
20 import org.apache.jdo.impl.model.jdo.JDOCollectionImplDynamic;
21 import org.apache.jdo.model.jdo.JDORelationship;
22 import org.apache.jdo.model.java.JavaType;
23
24 /***
25 * An instance of this class represents the JDO relationship metadata
26 * of a collection relationship field. This caching implementation
27 * caches any calulated value to avoid re-calculating it if it is
28 * requested again.
29 *
30 * @author Michael Bouschen
31 * @since 1.1
32 * @version 2.0
33 */
34 public class JDOCollectionImplCaching extends JDOCollectionImplDynamic {
35
36 /***
37 * Get the mappedBy relationship. If there is no mappedBy relationship
38 * set, the method checks the mappedBy name as specified in the declaring
39 * field and resolves the relationship. The method returns
40 * <code>null</code> if there is no mappedBy relationship set and there
41 * is no mappedBy name specified on the declaring field.
42 * @return the mappedBy relationship if available; <code>null</code>
43 * otherwise.
44 */
45 public JDORelationship getMappedBy() {
46 if (mappedBy == null) {
47 mappedBy = super.getMappedBy();
48 }
49 return mappedBy;
50 }
51
52 /***
53 * Get the inverse JDORelationship in the case of a two-way relationship.
54 * @return the inverse relationship
55 */
56 public JDORelationship getInverseRelationship() {
57 if (inverse == null) {
58 inverse = super.getInverseRelationship();
59 }
60 return inverse;
61 }
62
63 /***
64 * Determines whether the values of the elements should be stored if
65 * possible as part of the instance instead of as their own instances
66 * in the datastore.
67 * @return <code>true</code> if the elements should be stored as part of
68 * the instance; <code>false</code> otherwise
69 */
70 public boolean isEmbeddedElement() {
71 if (embeddedElement == null) {
72 embeddedElement =
73 super.isEmbeddedElement() ? Boolean.TRUE : Boolean.FALSE;
74 }
75 return (embeddedElement == null) ? false :
76 embeddedElement.booleanValue();
77 }
78
79 /***
80 * Get the type representation of the collection elements.
81 * @return the element type
82 */
83 public JavaType getElementType()
84 {
85 if (elementType == null) {
86 elementType = super.getElementType();
87 }
88 return elementType;
89 }
90
91 }