70 * @see Accessor.FieldReflection
71 * @see TransducedAccessor
72 */
73 public abstract class Accessor<BeanT, ValueT> implements Receiver {
74
75 public final Class<ValueT> valueType;
76
77 public Class<ValueT> getValueType() {
78 return valueType;
79 }
80
81 protected Accessor(Class<ValueT> valueType) {
82 this.valueType = valueType;
83 }
84
85 /**
86 * Returns the optimized version of the same accessor.
87 *
88 * @param context The {@link JAXBContextImpl} that owns the whole thing.
89 * (See {@link RuntimeModelBuilder#context}.)
90 * @return At least the implementation can return <tt>this</tt>.
91 */
92 public Accessor<BeanT, ValueT> optimize(@Nullable JAXBContextImpl context) {
93 return this;
94 }
95
96
97 /**
98 * Gets the value of the property of the given bean object.
99 *
100 * @param bean must not be null.
101 * @throws AccessorException if failed to set a value. For example, the getter method
102 * may throw an exception.
103 * @since 2.0 EA1
104 */
105 public abstract ValueT get(BeanT bean) throws AccessorException;
106
107 /**
108 * Sets the value of the property of the given bean object.
109 *
110 * @param bean must not be null.
|
70 * @see Accessor.FieldReflection
71 * @see TransducedAccessor
72 */
73 public abstract class Accessor<BeanT, ValueT> implements Receiver {
74
75 public final Class<ValueT> valueType;
76
77 public Class<ValueT> getValueType() {
78 return valueType;
79 }
80
81 protected Accessor(Class<ValueT> valueType) {
82 this.valueType = valueType;
83 }
84
85 /**
86 * Returns the optimized version of the same accessor.
87 *
88 * @param context The {@link JAXBContextImpl} that owns the whole thing.
89 * (See {@link RuntimeModelBuilder#context}.)
90 * @return At least the implementation can return {@code this}.
91 */
92 public Accessor<BeanT, ValueT> optimize(@Nullable JAXBContextImpl context) {
93 return this;
94 }
95
96
97 /**
98 * Gets the value of the property of the given bean object.
99 *
100 * @param bean must not be null.
101 * @throws AccessorException if failed to set a value. For example, the getter method
102 * may throw an exception.
103 * @since 2.0 EA1
104 */
105 public abstract ValueT get(BeanT bean) throws AccessorException;
106
107 /**
108 * Sets the value of the property of the given bean object.
109 *
110 * @param bean must not be null.
|