/** * Delegates any intercepted method to invoke a {@code static} method that is declared by the supplied type. To be considered * a valid delegation target, the target method must be visible and accessible to the instrumented type. This is the case if * the target type is either public or in the same package as the instrumented type and if the target method is either public * or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if * the interception is targeting the instrumented type. * * @param typeDescription The target type for the delegation. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(TypeDescription typeDescription) { return withDefaultConfiguration().to(typeDescription); }
/** * Delegates any intercepted method to invoke a constructor of the supplied type. To be considered a valid delegation target, * a constructor must be visible and accessible to the instrumented type. This is the case if the constructor's declaring type is * either public or in the same package as the instrumented type and if the constructor is either public or non-private and in * the same package as the instrumented type. Private constructors can only be used as a delegation target if the delegation is * targeting the instrumented type. * * @param type The type to construct. * @return A delegation that redirects method calls to a constructor of the supplied type. */ public static MethodDelegation toConstructor(Class<?> type) { return withDefaultConfiguration().toConstructor(type); }
/** * Delegates any intercepted method to invoke a constructor of the supplied type. To be considered a valid delegation target, * a constructor must be visible and accessible to the instrumented type. This is the case if the constructor's declaring type is * either public or in the same package as the instrumented type and if the constructor is either public or non-private and in * the same package as the instrumented type. Private constructors can only be used as a delegation target if the delegation is * targeting the instrumented type. * * @param typeDescription The type to construct. * @return A delegation that redirects method calls to a constructor of the supplied type. */ public static MethodDelegation toConstructor(TypeDescription typeDescription) { return withDefaultConfiguration().toConstructor(typeDescription); }
/** * Delegates any intercepted method to invoke a non-{@code static} method on the instance of the supplied field. To be * considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the * case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param name The field's name. * @return A delegation that redirects invocations to a method of the specified field's instance. */ public static MethodDelegation toField(String name) { return withDefaultConfiguration().toField(name); }
/** * Delegates any intercepted method to invoke a non-{@code static} method on the instance of the supplied field. To be * considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the * case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param name The field's name. * @param fieldLocatorFactory The field locator factory to use. * @return A delegation that redirects invocations to a method of the specified field's instance. */ public static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory) { return withDefaultConfiguration().toField(name, fieldLocatorFactory); }
/** * Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the * given name. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if * the method is either public or non-private and in the same package as the instrumented type. Private methods can only * be used as a delegation target if the delegation is targeting the instrumented type. * * @param name The name of the method that returns the delegation target. * @param methodGraphCompiler The method graph compiler to use. * @return A delegation that redirects invocations to the return value of a method that is declared by the instrumented type. */ public static MethodDelegation toMethodReturnOf(String name, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().toMethodReturnOf(name, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a {@code static} method that is declared by the supplied type. To be considered * a valid delegation target, the target method must be visible and accessible to the instrumented type. This is the case if * the target type is either public or in the same package as the instrumented type and if the target method is either public * or non-private and in the same package as the instrumented type. Private methods can only be used as a delegation target if * the interception is targeting the instrumented type. * * @param type The target type for the delegation. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Class<?> type) { return withDefaultConfiguration().to(type); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target) { return withDefaultConfiguration().to(target); }
/** * Delegates any intercepted method to invoke a method on an instance that is returned by a parameterless method of the * given name. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if * the method is either public or non-private and in the same package as the instrumented type. Private methods can only * be used as a delegation target if the delegation is targeting the instrumented type. * * @param name The name of the method that returns the delegation target. * @return A delegation that redirects invocations to the return value of a method that is declared by the instrumented type. */ public static MethodDelegation toMethodReturnOf(String name) { return withDefaultConfiguration().toMethodReturnOf(name); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param type The most specific type of which {@code target} should be considered. Must be a super type of the target's actual type. * @param fieldName The name of the field that is holding the {@code target} instance. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, Type type, String fieldName) { return withDefaultConfiguration().to(target, type, fieldName); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param methodGraphCompiler The method graph compiler to use. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().to(target, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param fieldName The name of the field that is holding the {@code target} instance. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, String fieldName) { return withDefaultConfiguration().to(target, fieldName); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param type The most specific type of which {@code target} should be considered. Must be a super type of the target's actual type. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, Type type) { return withDefaultConfiguration().to(target, type); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param type The most specific type of which {@code target} should be considered. Must be a super type of the target's actual type. * @param fieldName The name of the field that is holding the {@code target} instance. * @param methodGraphCompiler The method graph compiler to use. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, Type type, String fieldName, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().to(target, type, fieldName, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a non-{@code static} method on the instance of the supplied field. To be * considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the * case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param name The field's name. * @param methodGraphCompiler The method graph compiler to use. * @return A delegation that redirects invocations to a method of the specified field's instance. */ public static MethodDelegation toField(String name, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().toField(name, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param fieldName The name of the field that is holding the {@code target} instance. * @param methodGraphCompiler The method graph compiler to use. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, String fieldName, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().to(target, fieldName, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a non-{@code static} method on the instance of the supplied field. To be * considered a valid delegation target, a method must be visible and accessible to the instrumented type. This is the * case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param name The field's name. * @param fieldLocatorFactory The field locator factory to use. * @param methodGraphCompiler The method graph compiler to use. * @return A delegation that redirects invocations to a method of the specified field's instance. */ public static MethodDelegation toField(String name, FieldLocator.Factory fieldLocatorFactory, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().toField(name, fieldLocatorFactory, methodGraphCompiler); }
/** * Delegates any intercepted method to invoke a non-{@code static} method that is declared by the supplied type's instance or any * of its super types. To be considered a valid delegation target, a method must be visible and accessible to the instrumented type. * This is the case if the method's declaring type is either public or in the same package as the instrumented type and if the method * is either public or non-private and in the same package as the instrumented type. Private methods can only be used as * a delegation target if the delegation is targeting the instrumented type. * * @param target The target instance for the delegation. * @param type The most specific type of which {@code target} should be considered. Must be a super type of the target's actual type. * @param methodGraphCompiler The method graph compiler to use. * @return A method delegation that redirects method calls to a static method of the supplied type. */ public static MethodDelegation to(Object target, Type type, MethodGraph.Compiler methodGraphCompiler) { return withDefaultConfiguration().to(target, type, methodGraphCompiler); }
mocked = new WeakConcurrentSet<Class<?>>(WeakConcurrentSet.Cleaner.INLINE); String identifier = RandomString.make(); subclassEngine = new TypeCachingBytecodeGenerator(new SubclassBytecodeGenerator(withDefaultConfiguration() .withBinders(of(MockMethodAdvice.Identifier.class, identifier)) .to(MockMethodAdvice.ForReadObject.class), isAbstract().or(isNative()).or(isToString())), false);
.or(ElementMatchers.named("isPhantom")) .or(ElementMatchers.named("delete")))) .intercept(MethodDelegation.withDefaultConfiguration() .withBinders(FieldProxy.Binder .install(LiveObjectInterceptor.Getter.class,