View Javadoc
1   /*
2    * #%L
3    * EUGene :: EUGene
4    * %%
5    * Copyright (C) 2004 - 2010 CodeLutin
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
21   */
22  
23  package org.nuiton.eugene.models.object.xml;
24  
25  import org.nuiton.eugene.models.object.ObjectModelClassifier;
26  import org.nuiton.eugene.models.object.ObjectModelDependency;
27  
28  /**
29   * ObjectModelDependencyImpl.
30   *
31   * Created: april 23th 2009
32   *
33   * @author Florian Desbois - desbois@codelutin.com
34   */
35  public class ObjectModelDependencyImpl extends ObjectModelImplRef implements ObjectModelDependency {
36  
37      /**
38       * Supplier name from XML file
39       */
40      private String supplierName;
41  
42      /**
43       * Implementation of client to get the model when supplier is needed
44       */
45      private ObjectModelClassifierImpl client;
46  
47      private ObjectModelClassifier supplier;
48  
49      /**
50       * Method call for Digester setting properties of Dependency
51       *
52       * @param supplierName supplier name
53       */
54      public void setSupplierName(String supplierName) {
55          this.supplierName = supplierName;
56      }
57  
58      public String getSupplierName() {
59          return supplierName;
60      }
61  
62      /**
63       * The object instance of supplier is getting from model when supplier is null
64       *
65       * @return an ObjectModelClassifier corresponding to the supplier of the dependency
66       */
67      @Override
68      public ObjectModelClassifier getSupplier() {
69          if (supplier == null) {
70              ObjectModelClassifier classifier = client.getModel().getClassifier(supplierName);
71              supplier = classifier;
72          }
73          return supplier;
74      }
75  
76      public void setClient(ObjectModelClassifierImpl client) {
77          this.client = client;
78      }
79  
80      @Override
81      public ObjectModelClassifier getClient() {
82          return client;
83      }
84  
85  }