Class ClassVisitorFactory<T>

java.lang.Object
net.bytebuddy.asm.ClassVisitorFactory<T>
Type Parameters:
T - The type of the mapped class visitor.

@Enhance public abstract class ClassVisitorFactory<T> extends Object
A factory for wrapping a ClassVisitor in Byte Buddy's package namespace to a ClassVisitor in any other namespace. Note that this API does not allow for the passing of Attributes. which must be filtered or propagated past this translation. If the supplied visitors do not declare a method that Byte Buddy's version of ASM is aware of, an UnsupportedOperationException is thrown.
  • Constructor Details

    • ClassVisitorFactory

      protected ClassVisitorFactory(Class<?> type)
      Creates a new factory.
      Parameters:
      type - The type of the represented class visitor wrapper.
  • Method Details

    • getType

      public Class<?> getType()
      Returns the ClassVisitor type that this factory represents.
      Returns:
      The ClassVisitor type that this factory represents.
    • of

      public static <S> ClassVisitorFactory<S> of(Class<S> classVisitor)
      Returns a class visitor factory for the supplied ClassVisitor type.
      Type Parameters:
      S - The type of the class visitor to map to.
      Parameters:
      classVisitor - The type of the translated class visitor.
      Returns:
      A factory for wrapping ClassVisitors in Byte Buddy's and the supplied package namespace.
    • of

      public static <S> ClassVisitorFactory<S> of(Class<S> classVisitor, ByteBuddy byteBuddy)
      Returns a class visitor factory for the supplied ClassVisitor type.
      Type Parameters:
      S - The type of the class visitor to map to.
      Parameters:
      classVisitor - The type of the translated ClassVisitor.
      byteBuddy - The Byte Buddy instance to use.
      Returns:
      A factory for wrapping ClassVisitors in Byte Buddy's and the supplied package namespace.
    • wrap

      public abstract T wrap(org.objectweb.asm.ClassVisitor classVisitor)
      Wraps a ClassVisitor within an instance of the supplied class visitor type.
      Parameters:
      classVisitor - The class visitor to wrap.
      Returns:
      A class visitor that wraps the supplied class visitor.
    • unwrap

      public abstract org.objectweb.asm.ClassVisitor unwrap(T classVisitor)
      Unwraps an instance of the supplied class visitor as a ClassVisitor.
      Parameters:
      classVisitor - The class visitor to unwrap.
      Returns:
      A class visitor that unwraps the supplied class visitor.