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.
  • Field Details

  • Constructor Details

    • ForMethod

      public ForMethod(Transformer<MethodDescription.Token> transformer)
      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:
      transform in interface Transformer<MethodDescription>
      Parameters:
      instrumentedType - The instrumented type that declares the target being transformed.
      methodDescription - The target entity that is being transformed.
      Returns:
      The transformed instance.