Class BareAccessorFactory

java.lang.Object
dev.derklaro.reflexion.internal.bare.BareAccessorFactory
All Implemented Interfaces:
AccessorFactory

public final class BareAccessorFactory extends Object implements AccessorFactory
An accessor factory which creates accessors based on the plain java.lang.reflect members.
Since:
1.0
  • Constructor Details

    • BareAccessorFactory

      public BareAccessorFactory()
  • Method Details

    • makeAccessible

      private static void makeAccessible(@NotNull @NotNull AccessibleObject accessibleObject)
      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:
      isAvailable in interface AccessorFactory
      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:
      wrapField in interface AccessorFactory
      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:
      wrapMethod in interface AccessorFactory
      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:
      wrapConstructor in interface AccessorFactory
      Parameters:
      rfx - the base instance which tries to convert the constructor.
      ctr - the constructor to wrap.
      Returns:
      a wrapping accessor for the given constructor.