Package net.bytebuddy.dynamic
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 java.lang.Object implements Transformer<MethodDescription>
A transformer for a field that delegates to another transformer that transforms aMethodDescription.Token
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Transformer.ForMethod.MethodModifierTransformer
A transformer for a method's modifiers.protected static class
Transformer.ForMethod.TransformedMethod
The transformed method.-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.Transformer
Transformer.Compound<S>, Transformer.ForField, Transformer.ForMethod, Transformer.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description private Transformer<MethodDescription.Token>
transformer
The transformer to be applied.
-
Constructor Summary
Constructors Constructor Description ForMethod(Transformer<MethodDescription.Token> transformer)
Creates a new transforming method transformer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodDescription
transform(TypeDescription instrumentedType, MethodDescription methodDescription)
Transforms the supplied target.static Transformer<MethodDescription>
withModifiers(java.util.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 Detail
-
transformer
private final Transformer<MethodDescription.Token> transformer
The transformer to be applied.
-
-
Constructor Detail
-
ForMethod
public ForMethod(Transformer<MethodDescription.Token> transformer)
Creates a new transforming method transformer.- Parameters:
transformer
- The transformer to be applied.
-
-
Method Detail
-
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(java.util.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:
transform
in 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.
-
-