01: package net.sourceforge.orbroker;
02:
03: import java.lang.reflect.Method;
04:
05: import net.kildenpedersen.reflect.Reflector;
06:
07: /*
08: * Created on Mar 22, 2004
09: */
10:
11: /**
12: *
13: * @author Nils Kilden-Pedersen
14: */
15: final class SetProperty extends SetterMethod {
16:
17: /**
18: * Find the write method.
19: * @param roType The result-object type
20: * @param propertyName The set-property name
21: * @return write method for property
22: */
23: private static Method findWriteMethod(Class roType,
24: String propertyName) {
25: Method writeMethod = Reflector.getAccessibleWriteProperty(
26: roType, propertyName);
27: if (writeMethod != null) {
28: return writeMethod;
29: }
30: String msg = "No setter for property '" + propertyName
31: + "' found on class '" + Reflector.getClassName(roType)
32: + "'";
33: throw new ConfigurationException(msg);
34: }
35:
36: /**
37: * Constructor
38: * @param resultObjectType The result-object type
39: * @param propertyName The set-property name
40: */
41: SetProperty(Class resultObjectType, String propertyName) {
42: super (findWriteMethod(resultObjectType, propertyName));
43: }
44:
45: /**
46: * Returns the property type.
47: * @return property type
48: */
49: Class getPropertyType() {
50: return getParameterTypes()[0];
51: }
52: }
|