View Javadoc

1   /*
2    * Copyright 2006 Outsource Cafe, Inc.
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  package org.javagen.agile.oo.model;
17  
18  import javax.xml.bind.annotation.XmlAttribute;
19  import javax.xml.bind.annotation.XmlRootElement;
20  
21  import org.javagen.agile.core.annotation.DefaultValue;
22  import org.javagen.agile.core.model.AbstractModel;
23  import org.javagen.agile.core.model.Model;
24  
25  
26  /***
27   * Models a Object-Oriented class property or attribute.
28   *
29   * @author Richard Easterling
30   */
31  @XmlRootElement
32  public class Property extends AbstractModel {
33  
34      public static final String DEFAULT_MODEL_TYPE = "PROPERTY";
35      
36  	protected String type;
37      
38      protected String collectionType;
39      
40      protected Boolean navigable;
41  	
42  	public Property() {
43          setModelType(DEFAULT_MODEL_TYPE);
44  	}
45  
46      public Class getParentClass() {
47  		return (Class)parentModel;
48  	}
49  
50      @XmlAttribute
51   	public String getType() {
52  		return type;
53  	}
54  
55  	public void setType(String type) {
56  		this.type = type;
57  	}
58  
59      @XmlAttribute
60      public String getCollectionType() {
61          return collectionType;
62      }
63  
64      public void setCollectionType(String collection) {
65          this.collectionType = collection;
66      }
67  
68      @XmlAttribute
69      @DefaultValue("true")
70      public Boolean getNavigable() {
71          return navigable;
72      }
73  
74      public void setNavigable(Boolean navigable) {
75          this.navigable = navigable;
76      }
77  
78      @Override
79      public void copyTo(Model targetModel) {
80          Property target = (Property)targetModel;
81          super.copyTo(target);
82          if (this.getType()!=null)
83              target.setType(this.getType());
84          if (this.getNavigable()!=null)
85              target.setNavigable(this.getNavigable());
86      }
87  
88  	public String toString() {
89  		return (parentModel==null ? "<null class>" : parentModel.getName()) + "." + getName();
90  	}
91  }