Class BareAccessorFactory.BareFieldAccessor
java.lang.Object
dev.derklaro.reflexion.internal.bare.BareAccessorFactory.BareFieldAccessor
- All Implemented Interfaces:
BaseAccessor<Field>,FieldAccessor
- Enclosing class:
BareAccessorFactory
private static final class BareAccessorFactory.BareFieldAccessor
extends Object
implements FieldAccessor
A field accessor which invokes the bare java.lang.reflect field.
- Since:
- 1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBareFieldAccessor(@NotNull Field field, @NotNull Reflexion reflexion) Constructs a new bare field accessor instance. -
Method Summary
Modifier and TypeMethodDescription@NotNull FieldGet the java.lang.reflect member which is wrapped by this accessor.@NotNull ReflexionGet the reflexion instance which created this accessor instance.<T> @NotNull Result<T> getValue()Gets the value of the wrapped field using the instance the reflexion object which created this instance is bound to (but only if the field is not static).<T> @NotNull Result<T> Gets the value of the wrapped field using the given instance.Sets the value of the wrapped field using the instance the reflexion object which created this instance is bound to (but only if the field is not static).Sets the value of the wrapped field in the given object instance.
-
Field Details
-
field
-
reflexion
-
-
Constructor Details
-
BareFieldAccessor
-
-
Method Details
-
getMember
Get the java.lang.reflect member which is wrapped by this accessor.- Specified by:
getMemberin interfaceBaseAccessor<Field>- Returns:
- the wrapped member.
-
getReflexion
Get the reflexion instance which created this accessor instance.- Specified by:
getReflexionin interfaceBaseAccessor<Field>- Returns:
- the reflexion instance which created this instance.
-
getValue
Gets the value of the wrapped field using the instance the reflexion object which created this instance is bound to (but only if the field is not static). This method never throws an exception, all exceptions are given back to the caller in the returned result instance.- Specified by:
getValuein interfaceFieldAccessor- Type Parameters:
T- the type of the data returned from the field.- Returns:
- the result of the get operation, either holding the field value or a read exception.
-
getValue
Gets the value of the wrapped field using the given instance. This method never throws an exception, all exceptions are given back to the caller in the returned result instance.The given instance should be present in case the field is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the field is static, the instance will be ignored silently.
- Specified by:
getValuein interfaceFieldAccessor- Type Parameters:
T- the type of the data returned from the field.- Parameters:
instance- the instance to use when getting the field value.- Returns:
- the result of the get operation, either holding the field value or a read exception.
-
setValue
Sets the value of the wrapped field using the instance the reflexion object which created this instance is bound to (but only if the field is not static). This method never throws an exception, all exceptions are given back to the caller in the returned result instance.- Specified by:
setValuein interfaceFieldAccessor- Parameters:
value- the new value of the field.- Returns:
- the result of the set operation, either successful or holding the set exception.
-
setValue
@NotNull public @NotNull Result<Void> setValue(@Nullable @Nullable Object instance, @Nullable @Nullable Object value) Sets the value of the wrapped field in the given object instance. This method never throws an exception, all exceptions are given back to the caller in the returned result instance.The given instance should be present in case the field is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the field is static, the instance will be ignored silently.
- Specified by:
setValuein interfaceFieldAccessor- Parameters:
instance- the instance of the object to set the new field value in.value- the new value of the field to set.- Returns:
- the result of the set operation, either successful or holding the set exception.
-