Interface AccessorFactory

All Known Implementing Classes:
BareAccessorFactory, MethodHandleAccessorFactory

public interface AccessorFactory
A conversion factory from java reflection types to reflexion wrappers of them. A factory should be designed in a way that there is no exception thrown when initializing it. Exceptions should be ignored but isAvailable() should then return false to indicate that the factory is not available for the current environment.

External factories are accepted as well when being provided as a service to the current jvm. Note that the default factories will always be under consideration as well.

Since:
1.0
  • Method Details

    • isAvailable

      boolean isAvailable()
      Checks if this factory is available. This method should never throw an exception but can decide the return value based on one.
      Returns:
      true if this factory is available, false otherwise.
    • wrapField

      @NotNull @NotNull FieldAccessor wrapField(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Field field)
      Wraps the given java.lang.reflect field into a reflexion FieldAccessor wrapper.
      Parameters:
      reflexion - the base instance which tries to convert the field.
      field - the field to wrap.
      Returns:
      a wrapping accessor for the given field.
      Throws:
      NullPointerException - if the given reflexion instance or field is null.
      ReflexionException - if the factory is unable to wrap the given field.
    • wrapMethod

      @NotNull @NotNull MethodAccessor<Method> wrapMethod(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Method method)
      Wraps the given java.lang.reflect method into a reflexion MethodAccessor wrapper.
      Parameters:
      reflexion - the base instance which tries to convert the method.
      method - the method to wrap.
      Returns:
      a wrapping accessor for the given method.
      Throws:
      NullPointerException - if the given reflexion instance or method is null.
      ReflexionException - if the factory is unable to wrap the given method.
    • wrapConstructor

      @NotNull @NotNull MethodAccessor<Constructor<?>> wrapConstructor(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Constructor<?> ct)
      Wraps the given java.lang.reflect constructor into a reflexion MethodAccessor wrapper.
      Parameters:
      reflexion - the base instance which tries to convert the constructor.
      ct - the constructor to wrap.
      Returns:
      a wrapping accessor for the given constructor.
      Throws:
      NullPointerException - if the given reflexion instance or constructor is null.
      ReflexionException - if the factory is unable to wrap the given constructor.