Interface ReflectiveProxyObject


@Experimental public interface ReflectiveProxyObject
All interfaces used for XReflection.proxify(Class) must extend this interface. Instances of this class can be thought as a dynamic Class object that contains methods, fields and constructors, whether final or static, but all in forms of public methods.

The first instance of this class should be used for only calling constructors, static methods and fields, and bindTo(Object) method. However, it's possible to create two separate classes for constructors and static members and one for non-static members without constructors.

Since:
13.0.0
See Also:
  • Method Details

    • instance

      @NotNull @NonExtendable @Contract(pure=true) @NotNull Object instance()
      Gets the instance that the methods are delegating to. Throw an exception if used on the factory object.
    • getTargetClass

      @NotNull @NonExtendable @Contract(pure=true) @NotNull Class<?> getTargetClass()
      Get the real class object that this proxy object is referencing.
      Since:
      14.0.0
    • isInstance

      @NotNull @NonExtendable @Contract(pure=true) @org.jetbrains.annotations.NotNull boolean isInstance(@Nullable @Nullable Object object)
      Equivalent to the code:
      object instanceof TargetClass
      This results in more performance in generated code instead of doing:
      getTargetClass().isInstance(object.getClass())
      So do note that this will never return true if you pass a ReflectiveProxyObject to it.
      Since:
      14.0.0
    • bindTo

      @NotNull @OverrideOnly @Contract(value="_ -> new", pure=true) @NotNull ReflectiveProxyObject bindTo(@NotNull @NotNull Object instance)
      Returns a new ReflectiveProxyObject that's linked to a new ReflectiveProxy with the given instance.
      Parameters:
      instance - the instance to bind.