Class Helpers


  • public class Helpers
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Set<java.lang.String> OBJECT_METHOD_NAMES  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T createProxy​(java.lang.Class<T> cls, MethodCallListener listener)
      Creates a transparent proxy instance for the given class.
      static <T> T createProxy​(java.lang.Class<T> cls, java.lang.Object[] constructorArgs, java.lang.Class<?>[] constructorArgTypes, MethodCallListener listener)
      Creates a transparent proxy instance for the given class.
      static <T> T createProxy​(java.lang.Class<T> cls, java.lang.Object[] constructorArgs, java.lang.Class<?>[] constructorArgTypes, java.util.Collection<MethodCallListener> listeners)
      Creates a transparent proxy instance for the given class.
      static <T> T createProxy​(java.lang.Class<T> cls, java.lang.Object[] constructorArgs, java.lang.Class<?>[] constructorArgTypes, java.util.Collection<MethodCallListener> listeners, net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.method.MethodDescription> extraMethodMatcher)
      Creates a transparent proxy instance for the given class.
      static <T> T createProxy​(java.lang.Class<T> cls, java.util.Collection<MethodCallListener> listeners)
      Creates a transparent proxy instance for the given class.
      • Methods inherited from class java.lang.Object

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

      • OBJECT_METHOD_NAMES

        public static final java.util.Set<java.lang.String> OBJECT_METHOD_NAMES
    • Method Detail

      • createProxy

        public static <T> T createProxy​(java.lang.Class<T> cls,
                                        java.lang.Object[] constructorArgs,
                                        java.lang.Class<?>[] constructorArgTypes,
                                        java.util.Collection<MethodCallListener> listeners)
        Creates a transparent proxy instance for the given class. It is possible to provide one or more method execution listeners or replace particular method calls completely. Callbacks defined in these listeners are going to be called when any **public** method of the given class is invoked. Overridden callbacks are expected to be skipped if they throw NotImplementedException.
        Type Parameters:
        T - Any class derived from Object
        Parameters:
        cls - the class to which the proxy should be created. Must not be an interface.
        constructorArgs - Array of constructor arguments. Could be an empty array if the class provides a constructor without arguments.
        constructorArgTypes - Array of constructor argument types. Must represent types of constructorArgs.
        listeners - One or more method invocation listeners.
        Returns:
        Proxy instance
      • createProxy

        public static <T> T createProxy​(java.lang.Class<T> cls,
                                        java.lang.Object[] constructorArgs,
                                        java.lang.Class<?>[] constructorArgTypes,
                                        java.util.Collection<MethodCallListener> listeners,
                                        @Nullable
                                        net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.method.MethodDescription> extraMethodMatcher)
        Creates a transparent proxy instance for the given class. It is possible to provide one or more method execution listeners or replace particular method calls completely. Callbacks defined in these listeners are going to be called when any **public** method of the given class is invoked. Overridden callbacks are expected to be skipped if they throw NotImplementedException. !!! This API is designed for private usage.
        Type Parameters:
        T - Any class derived from Object
        Parameters:
        cls - The class to which the proxy should be created. Must not be an interface.
        constructorArgs - Array of constructor arguments. Could be an empty array if the class provides a constructor without arguments.
        constructorArgTypes - Array of constructor argument types. Must represent types of constructorArgs.
        listeners - One or more method invocation listeners.
        extraMethodMatcher - Optional additional method proxy conditions
        Returns:
        Proxy instance
      • createProxy

        public static <T> T createProxy​(java.lang.Class<T> cls,
                                        java.util.Collection<MethodCallListener> listeners)
        Creates a transparent proxy instance for the given class. It is possible to provide one or more method execution listeners or replace particular method calls completely. Callbacks defined in these listeners are going to be called when any **public** method of the given class is invoked. Overridden callbacks are expected to be skipped if they throw NotImplementedException.
        Type Parameters:
        T - Any class derived from Object
        Parameters:
        cls - the class to which the proxy should be created. Must not be an interface. Must expose a constructor without arguments.
        listeners - One or more method invocation listeners.
        Returns:
        Proxy instance
      • createProxy

        public static <T> T createProxy​(java.lang.Class<T> cls,
                                        MethodCallListener listener)
        Creates a transparent proxy instance for the given class. It is possible to provide one or more method execution listeners or replace particular method calls completely. Callbacks defined in these listeners are going to be called when any **public** method of the given class is invoked. Overridden callbacks are expected to be skipped if they throw NotImplementedException.
        Type Parameters:
        T - Any class derived from Object
        Parameters:
        cls - the class to which the proxy should be created. Must not be an interface. Must expose a constructor without arguments.
        listener - Method invocation listener.
        Returns:
        Proxy instance
      • createProxy

        public static <T> T createProxy​(java.lang.Class<T> cls,
                                        java.lang.Object[] constructorArgs,
                                        java.lang.Class<?>[] constructorArgTypes,
                                        MethodCallListener listener)
        Creates a transparent proxy instance for the given class. It is possible to provide one or more method execution listeners or replace particular method calls completely. Callbacks defined in these listeners are going to be called when any **public** method of the given class is invoked. Overridden callbacks are expected to be skipped if they throw NotImplementedException.
        Type Parameters:
        T - Any class derived from Object
        Parameters:
        cls - the class to which the proxy should be created. Must not be an interface.
        constructorArgs - Array of constructor arguments. Could be an empty array if the class provides a constructor without arguments.
        constructorArgTypes - Array of constructor argument types. Must represent types of constructorArgs.
        listener - Method invocation listener.
        Returns:
        Proxy instance