1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.core.api.reflect;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26
27
28
29
30
31 public class ObjectDefinition implements Serializable {
32
33 private static final long serialVersionUID = 835423601196288352L;
34
35 private String className;
36 private String applicationId;
37 private boolean atRemotingLayer;
38 private final List<DataDefinition> constructorParameters = new ArrayList<DataDefinition>();
39 private final Map<String, PropertyDefinition> properties = new HashMap<String, PropertyDefinition>();
40
41 public ObjectDefinition(Class<?> objectClass) {
42 this(objectClass.getName());
43 }
44
45 public ObjectDefinition(String className, String applicationId) {
46 this.className = className;
47 this.applicationId = applicationId;
48 }
49
50 public ObjectDefinition(String className) {
51 if (className == null) {
52 throw new IllegalArgumentException("Extension class name cannot be null");
53 }
54 this.className = className;
55 }
56
57 public String getClassName() {
58 return this.className;
59 }
60
61 public void addConstructorParameter(DataDefinition parameter) {
62 this.constructorParameters.add(parameter);
63 }
64
65 public void removeConstructorParameter(DataDefinition parameter) {
66 this.constructorParameters.remove(parameter);
67 }
68
69 public void setConstructorParameters(List<DataDefinition> parameters) {
70 this.constructorParameters.clear();
71 this.constructorParameters.addAll(parameters);
72 }
73
74 public List<DataDefinition> getConstructorParameters() {
75 return this.constructorParameters;
76 }
77
78 public void addProperty(PropertyDefinition property) {
79 if (property == null) {
80 return;
81 }
82 if (property.getName() == null) {
83 throw new IllegalArgumentException("PropertyDefinition cannot have a null name.");
84 }
85 this.properties.put(property.getName(), property);
86 }
87
88 public PropertyDefinition getProperty(String name) {
89 return (PropertyDefinition) this.properties.get(name);
90 }
91
92 public Collection<PropertyDefinition> getProperties() {
93 return this.properties.values();
94 }
95
96 public void setProperties(Collection<PropertyDefinition> properties) {
97 this.properties.clear();
98 if (properties == null) {
99 return;
100 }
101 for (PropertyDefinition prop: properties) {
102 addProperty(prop);
103 }
104 }
105
106 public String toString() {
107 return "[ObjectDefinition: className: " + getClassName()
108 + ", applicationId: " + getApplicationId()
109 + "]";
110 }
111
112 public boolean isAtRemotingLayer() {
113 return this.atRemotingLayer;
114 }
115
116 public void setAtRemotingLayer(boolean atRemotingLayer) {
117 this.atRemotingLayer = atRemotingLayer;
118 }
119
120 public String getApplicationId() {
121 return this.applicationId;
122 }
123
124 public void setApplicationId(String applicationId) {
125 this.applicationId = applicationId;
126 }
127 }