01: package dalma.container.model;
02:
03: import java.lang.reflect.Field;
04:
05: /**
06: * {@link Injector} that sets a field.
07: * @author Kohsuke Kawaguchi
08: */
09: final class FieldInjector<T, V> extends Injector<T, V> {
10: private final Field f;
11:
12: public FieldInjector(Field f) {
13: this .f = f;
14: }
15:
16: public String getName() {
17: return f.getName();
18: }
19:
20: public Class<V> _getType() {
21: return (Class<V>) f.getType();
22: }
23:
24: public void set(T target, V value) throws InjectionException {
25: try {
26: f.set(target, value);
27: } catch (IllegalAccessException e) {
28: throw new InjectionException(e);
29: }
30: }
31: }
|