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