Class BareAccessorFactory.BareConstructorAccessor

java.lang.Object
dev.derklaro.reflexion.internal.bare.BareAccessorFactory.BareConstructorAccessor
All Implemented Interfaces:
BaseAccessor<Constructor<?>>, MethodAccessor<Constructor<?>>
Enclosing class:
BareAccessorFactory

private static final class BareAccessorFactory.BareConstructorAccessor extends Object implements MethodAccessor<Constructor<?>>
A constructor accessor which invokes constructors based on the given bare constructor.
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Constructor<?>
     
    private final Reflexion
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BareConstructorAccessor(@NotNull Reflexion reflexion, @NotNull Constructor<?> constructor)
    Constructs a new bare constructor accessor instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Constructor<?>
    Get the java.lang.reflect member which is wrapped by this accessor.
    @NotNull Reflexion
    Get the reflexion instance which created this accessor instance.
    <V> @NotNull Result<V>
    Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static).
    <V> @NotNull Result<V>
    invoke(@Nullable Object instance)
    Invokes the underlying method using the given instance.
    <V> @NotNull Result<V>
    invoke(@Nullable Object instance, @NotNull Object... args)
    Invokes the underlying method using the given instance.
    <V> @NotNull Result<V>
    invokeWithArgs(@NotNull Object... args)
    Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • reflexion

      private final Reflexion reflexion
    • constructor

      private final Constructor<?> constructor
  • Constructor Details

    • BareConstructorAccessor

      public BareConstructorAccessor(@NotNull @NotNull Reflexion reflexion, @NotNull @NotNull Constructor<?> constructor)
      Constructs a new bare constructor accessor instance.
      Parameters:
      reflexion - the reflexion which produced this instance.
      constructor - the constructor to wrap.
  • Method Details

    • getMember

      @NotNull public @NotNull Constructor<?> getMember()
      Get the java.lang.reflect member which is wrapped by this accessor.
      Specified by:
      getMember in interface BaseAccessor<Constructor<?>>
      Returns:
      the wrapped member.
    • getReflexion

      @NotNull public @NotNull Reflexion getReflexion()
      Get the reflexion instance which created this accessor instance.
      Specified by:
      getReflexion in interface BaseAccessor<Constructor<?>>
      Returns:
      the reflexion instance which created this instance.
    • invoke

      @NotNull public <V> @NotNull Result<V> invoke()
      Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static). This method never throws an exception all exceptions are given back to the caller in the returned result instance.

      This method invokes the wrapped method without any arguments.

      Specified by:
      invoke in interface MethodAccessor<Constructor<?>>
      Type Parameters:
      V - the type of values returned by the wrapped method.
      Returns:
      the result instance of the invocation, either holding the result of the method or any exception thrown.
    • invoke

      @NotNull public <V> @NotNull Result<V> invoke(@Nullable @Nullable Object instance)
      Invokes the underlying method using the given instance. This method never throws an exception all exceptions are given back to the caller in the returned result instance.

      This method invokes the wrapped method without any arguments. The given instance should be present in case the method is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the method is static, the instance will be ignored silently.

      Specified by:
      invoke in interface MethodAccessor<Constructor<?>>
      Type Parameters:
      V - the type of values returned by the wrapped method.
      Parameters:
      instance - the instance to invoke the wrapped method on.
      Returns:
      the result instance of the invocation, either holding the result of the method or any exception thrown.
    • invokeWithArgs

      @NotNull public <V> @NotNull Result<V> invokeWithArgs(@NotNull @NotNull Object... args)
      Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static). This method never throws an exception all exceptions are given back to the caller in the returned result instance.
      Specified by:
      invokeWithArgs in interface MethodAccessor<Constructor<?>>
      Type Parameters:
      V - the type of values returned by the wrapped method.
      Parameters:
      args - the arguments to use on when invoking the wrapped method.
      Returns:
      the result instance of the invocation, either holding the result of the method or any exception thrown.
    • invoke

      @NotNull public <V> @NotNull Result<V> invoke(@Nullable @Nullable Object instance, @NotNull @NotNull Object... args)
      Invokes the underlying method 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 method is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the method is static, the instance will be ignored silently.

      Specified by:
      invoke in interface MethodAccessor<Constructor<?>>
      Type Parameters:
      V - the type of values returned by the wrapped method.
      Parameters:
      instance - the instance to invoke the wrapped method on.
      args - the arguments to use on when invoking the wrapped method.
      Returns:
      the result instance of the invocation, either holding the result of the method or any exception thrown.