Class BareAccessorFactory
java.lang.Object
dev.derklaro.reflexion.internal.bare.BareAccessorFactory
- All Implemented Interfaces:
AccessorFactory
An accessor factory which creates accessors based on the plain java.lang.reflect members.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classA constructor accessor which invokes constructors based on the given bare constructor.private static final classA field accessor which invokes the bare java.lang.reflect field.private static final classA method accessor which invokes the given bare method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this factory is available.private static voidmakeAccessible(@NotNull AccessibleObject accessibleObject) Makes the given accessible object accessible, either using force through sun.misc.Unsafe or by using direct access to AccessibleObject.setAccessible.@NotNull MethodAccessor<Constructor<?>> wrapConstructor(@NotNull Reflexion rfx, @NotNull Constructor<?> ctr) Wraps the given java.lang.reflect constructor into a reflexion MethodAccessor wrapper.@NotNull FieldAccessorWraps the given java.lang.reflect field into a reflexion FieldAccessor wrapper.@NotNull MethodAccessor<Method> wrapMethod(@NotNull Reflexion reflexion, @NotNull Method method) Wraps the given java.lang.reflect method into a reflexion MethodAccessor wrapper.
-
Constructor Details
-
BareAccessorFactory
public BareAccessorFactory()
-
-
Method Details
-
makeAccessible
Makes the given accessible object accessible, either using force through sun.misc.Unsafe or by using direct access to AccessibleObject.setAccessible. Exceptions caused by this method are not caught.On Java 9 or later this method might throw an InaccessibleObjectException.
- Parameters:
accessibleObject- the object ot make accessible.- Throws:
NullPointerException- if the given object is null.- Since:
- 1.6
-
isAvailable
public boolean isAvailable()Checks if this factory is available. This method should never throw an exception but can decide the return value based on one.- Specified by:
isAvailablein interfaceAccessorFactory- Returns:
- true if this factory is available, false otherwise.
-
wrapField
@NotNull public @NotNull FieldAccessor wrapField(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Field field) Wraps the given java.lang.reflect field into a reflexion FieldAccessor wrapper.- Specified by:
wrapFieldin interfaceAccessorFactory- Parameters:
reflexion- the base instance which tries to convert the field.field- the field to wrap.- Returns:
- a wrapping accessor for the given field.
-
wrapMethod
@NotNull public @NotNull MethodAccessor<Method> wrapMethod(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Method method) Wraps the given java.lang.reflect method into a reflexion MethodAccessor wrapper.- Specified by:
wrapMethodin interfaceAccessorFactory- Parameters:
reflexion- the base instance which tries to convert the method.method- the method to wrap.- Returns:
- a wrapping accessor for the given method.
-
wrapConstructor
@NotNull public @NotNull MethodAccessor<Constructor<?>> wrapConstructor(@NotNull @NotNull Reflexion rfx, @NotNull @NotNull Constructor<?> ctr) Wraps the given java.lang.reflect constructor into a reflexion MethodAccessor wrapper.- Specified by:
wrapConstructorin interfaceAccessorFactory- Parameters:
rfx- the base instance which tries to convert the constructor.ctr- the constructor to wrap.- Returns:
- a wrapping accessor for the given constructor.
-