Class ClassProxyFactory

  • All Implemented Interfaces:
    IProxyFactory

    public class ClassProxyFactory
    extends java.lang.Object
    implements IProxyFactory
    Factory generating a mock for a class.
    • Field Detail

      • defaultClassInfoProviders

        private static final ClassInfoProvider[] defaultClassInfoProviders
      • jdkClassInfoProviders

        private static final ClassInfoProvider[] jdkClassInfoProviders
      • id

        private static final java.util.concurrent.atomic.AtomicInteger id
      • currentData

        private static final java.lang.ThreadLocal<ClassMockingData> currentData
      • typeCache

        private final net.bytebuddy.TypeCache<java.lang.Class<?>> typeCache
    • Constructor Detail

      • ClassProxyFactory

        public ClassProxyFactory()
    • Method Detail

      • isCallerMockInvocationHandlerInvoke

        public static boolean isCallerMockInvocationHandlerInvoke​(java.lang.Throwable e)
      • createProxy

        public <T> T createProxy​(java.lang.Class<T> toMock,
                                 java.lang.reflect.InvocationHandler handler,
                                 java.lang.reflect.Method[] mockedMethods,
                                 ConstructorArgs args)
        Specified by:
        createProxy in interface IProxyFactory
        Type Parameters:
        T - type of the class to mock
        Parameters:
        toMock - the class to mock by the factory
        handler - the handler that will be linked to the created proxy
        mockedMethods - the subset of toMock's methods to mock, or null to mock all methods.
        args - the constructor arguments to use, or null to use heuristics to choose a constructor.
        Returns:
        the newly created proxy
      • isJdkClassOrWithoutPackage

        private static <T> boolean isJdkClassOrWithoutPackage​(java.lang.Class<T> toMock)
      • classLoadingStrategy

        private net.bytebuddy.dynamic.loading.ClassLoadingStrategy<java.lang.ClassLoader> classLoadingStrategy()
      • getInvocationHandler

        public java.lang.reflect.InvocationHandler getInvocationHandler​(java.lang.Object mock)
        Description copied from interface: IProxyFactory
        Returns the invocation handler for mock;
        Specified by:
        getInvocationHandler in interface IProxyFactory
        Parameters:
        mock - a mock instance previously returned by createProxy.
        Returns:
        the handler handling method calls for the mock
      • getCallbackGetter

        private static java.lang.invoke.MethodHandle getCallbackGetter​(java.lang.Object mock)
      • getCallbackSetter

        private static java.lang.invoke.MethodHandle getCallbackSetter​(java.lang.Object mock)