View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at 
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software 
11   * distributed under the License is distributed on an "AS IS" BASIS, 
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  
17  package org.apache.jdo.impl.model.jdo.caching;
18  
19  import org.apache.jdo.model.jdo.JDORelationship;
20  import org.apache.jdo.impl.model.jdo.JDOReferenceImplDynamic;
21  
22  /***
23   * An instance of this class represents the JDO relationship metadata 
24   * of a reference relationship field. This caching implementation
25   * caches any calulated value to avoid re-calculating it if it is
26   * requested again. 
27   *
28   * @author Michael Bouschen
29   * @since 2.0
30   * @version 2.0
31   */
32  public class JDOReferenceImplCaching extends JDOReferenceImplDynamic {
33      
34      /*** 
35       * Get the mappedBy relationship. If there is no mappedBy relationship
36       * set, the method checks the mappedBy name as specified in the declaring
37       * field and resolves the relationship. The method returns
38       * <code>null</code> if there is no mappedBy relationship set and there
39       * is no mappedBy name specified on the declaring field.
40       * @return the mappedBy relationship if available; <code>null</code>
41       * otherwise.
42       */
43      public JDORelationship getMappedBy() {
44          if (mappedBy == null) {
45              mappedBy = super.getMappedBy();
46          }
47          return mappedBy;
48      }
49  
50      /***
51       * Get the inverse JDORelationship in the case of a two-way relationship.
52       * @return the inverse relationship
53       */
54      public JDORelationship getInverseRelationship() {
55          if (inverse == null) {
56              inverse = super.getInverseRelationship();
57          }
58          return inverse;
59      }
60  }