Class ScalaAnnotationRemovalVisitor

java.lang.Object
io.micronaut.scala.processing.test.ScalaAnnotationRemovalVisitor
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.core.util.Toggleable, io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>

public final class ScalaAnnotationRemovalVisitor extends Object implements io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
Test visitor that takes annotations off a visited class.

Removal is the half of element mutation nothing here could reach. ScalaElementMutationVisitor only adds, and adding is forgiving: an annotation written twice is the same as written once. Taking one away has to reach the same metadata the plugin built, and a removal that silently misses leaves the bean exactly as it was.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The kind of removal to perform.

    Nested classes/interfaces inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind
     
    static <T> T
    removing(ScalaAnnotationRemovalVisitor.Mode mode, String annotationName, @Nullable String replacement, Supplier<T> supplier)
    Executes a compilation with this visitor removing the given annotation and adding another.
    static <T> T
    removing(ScalaAnnotationRemovalVisitor.Mode mode, String annotationName, Supplier<T> supplier)
    Executes a compilation with this visitor removing the given annotation.
    void
    visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.util.Toggleable

    isEnabled

    Methods inherited from interface io.micronaut.inject.visitor.TypeElementVisitor

    finish, getClassType, getElementType, getSupportedAnnotationNames, getSupportedOptions, query, start, visitConstructor, visitEnumConstant, visitField, visitMethod
  • Constructor Details

    • ScalaAnnotationRemovalVisitor

      public ScalaAnnotationRemovalVisitor()
  • Method Details

    • removing

      public static <T> T removing(ScalaAnnotationRemovalVisitor.Mode mode, String annotationName, Supplier<T> supplier)
      Executes a compilation with this visitor removing the given annotation.
      Type Parameters:
      T - The result type
      Parameters:
      mode - The removal to perform
      annotationName - The annotation to remove
      supplier - The compilation work
      Returns:
      The supplier result
    • removing

      public static <T> T removing(ScalaAnnotationRemovalVisitor.Mode mode, String annotationName, @Nullable @Nullable String replacement, Supplier<T> supplier)
      Executes a compilation with this visitor removing the given annotation and adding another.
      Type Parameters:
      T - The result type
      Parameters:
      mode - The removal to perform
      annotationName - The annotation to remove
      replacement - The annotation to add in its place
      supplier - The compilation work
      Returns:
      The supplier result
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered
    • visitClass

      public void visitClass(io.micronaut.inject.ast.ClassElement element, io.micronaut.inject.visitor.VisitorContext context)
      Specified by:
      visitClass in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>
    • getVisitorKind

      public io.micronaut.inject.visitor.TypeElementVisitor.VisitorKind getVisitorKind()
      Specified by:
      getVisitorKind in interface io.micronaut.inject.visitor.TypeElementVisitor<Object,Object>