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 | 0 | private final List<DataDefinition> constructorParameters = new ArrayList<DataDefinition>(); |
38 | 0 | private final Map<String, PropertyDefinition> properties = new HashMap<String, PropertyDefinition>(); |
39 | |
|
40 | |
public ObjectDefinition(Class<?> objectClass) { |
41 | 0 | this(objectClass.getName()); |
42 | 0 | } |
43 | |
|
44 | 0 | public ObjectDefinition(String className, String applicationId) { |
45 | 0 | this.className = className; |
46 | 0 | this.applicationId = applicationId; |
47 | 0 | } |
48 | |
|
49 | 0 | public ObjectDefinition(String className) { |
50 | 0 | if (className == null) { |
51 | 0 | throw new IllegalArgumentException("Extension class name cannot be null"); |
52 | |
} |
53 | 0 | this.className = className; |
54 | 0 | } |
55 | |
|
56 | |
public String getClassName() { |
57 | 0 | return this.className; |
58 | |
} |
59 | |
|
60 | |
public void addConstructorParameter(DataDefinition parameter) { |
61 | 0 | this.constructorParameters.add(parameter); |
62 | 0 | } |
63 | |
|
64 | |
public void removeConstructorParameter(DataDefinition parameter) { |
65 | 0 | this.constructorParameters.remove(parameter); |
66 | 0 | } |
67 | |
|
68 | |
public void setConstructorParameters(List<DataDefinition> parameters) { |
69 | 0 | this.constructorParameters.clear(); |
70 | 0 | this.constructorParameters.addAll(parameters); |
71 | 0 | } |
72 | |
|
73 | |
public List<DataDefinition> getConstructorParameters() { |
74 | 0 | return this.constructorParameters; |
75 | |
} |
76 | |
|
77 | |
public void addProperty(PropertyDefinition property) { |
78 | 0 | if (property == null) { |
79 | 0 | return; |
80 | |
} |
81 | 0 | if (property.getName() == null) { |
82 | 0 | throw new IllegalArgumentException("PropertyDefinition cannot have a null name."); |
83 | |
} |
84 | 0 | this.properties.put(property.getName(), property); |
85 | 0 | } |
86 | |
|
87 | |
public PropertyDefinition getProperty(String name) { |
88 | 0 | return (PropertyDefinition) this.properties.get(name); |
89 | |
} |
90 | |
|
91 | |
public Collection<PropertyDefinition> getProperties() { |
92 | 0 | return this.properties.values(); |
93 | |
} |
94 | |
|
95 | |
public void setProperties(Collection<PropertyDefinition> properties) { |
96 | 0 | this.properties.clear(); |
97 | 0 | if (properties == null) { |
98 | 0 | return; |
99 | |
} |
100 | 0 | for (PropertyDefinition prop: properties) { |
101 | 0 | addProperty(prop); |
102 | |
} |
103 | 0 | } |
104 | |
|
105 | |
public String toString() { |
106 | 0 | return "[ObjectDefinition: className: " + getClassName() |
107 | |
+ ", applicationId: " + getApplicationId() |
108 | |
+ "]"; |
109 | |
} |
110 | |
|
111 | |
public boolean isAtRemotingLayer() { |
112 | 0 | return this.atRemotingLayer; |
113 | |
} |
114 | |
|
115 | |
public void setAtRemotingLayer(boolean atRemotingLayer) { |
116 | 0 | this.atRemotingLayer = atRemotingLayer; |
117 | 0 | } |
118 | |
|
119 | |
public String getApplicationId() { |
120 | 0 | return this.applicationId; |
121 | |
} |
122 | |
|
123 | |
public void setApplicationId(String applicationId) { |
124 | 0 | this.applicationId = applicationId; |
125 | 0 | } |
126 | |
} |