Class Transformer.ForMethod
java.lang.Object
net.bytebuddy.dynamic.Transformer.ForMethod
- All Implemented Interfaces:
Transformer<MethodDescription>
- Enclosing interface:
Transformer<T>
@Enhance
public static class Transformer.ForMethod
extends Object
implements Transformer<MethodDescription>
A transformer for a field that delegates to another transformer that transforms a
MethodDescription.Token.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA transformer for a method's modifiers.protected static classThe transformed method.Nested classes/interfaces inherited from interface Transformer
Transformer.Compound<S>, Transformer.ForField, Transformer.ForMethod, Transformer.NoOp -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Transformer<MethodDescription.Token> The transformer to be applied. -
Constructor Summary
ConstructorsConstructorDescriptionForMethod(Transformer<MethodDescription.Token> transformer) Creates a new transforming method transformer. -
Method Summary
Modifier and TypeMethodDescriptiontransform(TypeDescription instrumentedType, MethodDescription methodDescription) Transforms the supplied target.static Transformer<MethodDescription> withModifiers(List<? extends ModifierContributor.ForMethod> modifierContributors) Creates a transformer that enforces the supplied modifier contributors.static Transformer<MethodDescription> withModifiers(ModifierContributor.ForMethod... modifierContributor) Creates a transformer that enforces the supplied modifier contributors.
-
Field Details
-
transformer
The transformer to be applied.
-
-
Constructor Details
-
ForMethod
Creates a new transforming method transformer.- Parameters:
transformer- The transformer to be applied.
-
-
Method Details
-
withModifiers
public static Transformer<MethodDescription> withModifiers(ModifierContributor.ForMethod... modifierContributor) Creates a transformer that enforces the supplied modifier contributors. All ranges of each contributor is first cleared and then overridden by the specified modifiers in the order they are supplied.- Parameters:
modifierContributor- The modifier transformers in their application order.- Returns:
- A method transformer where each method's modifiers are adapted to the given modifiers.
-
withModifiers
public static Transformer<MethodDescription> withModifiers(List<? extends ModifierContributor.ForMethod> modifierContributors) Creates a transformer that enforces the supplied modifier contributors. All ranges of each contributor is first cleared and then overridden by the specified modifiers in the order they are supplied.- Parameters:
modifierContributors- The modifier contributors in their application order.- Returns:
- A method transformer where each method's modifiers are adapted to the given modifiers.
-
transform
public MethodDescription transform(TypeDescription instrumentedType, MethodDescription methodDescription) Transforms the supplied target.- Specified by:
transformin interfaceTransformer<MethodDescription>- Parameters:
instrumentedType- The instrumented type that declares the target being transformed.methodDescription- The target entity that is being transformed.- Returns:
- The transformed instance.
-