1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }