View Javadoc

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