Class PluginUtils

java.lang.Object
io.micronaut.sourcegen.generator.visitors.PluginUtils

@Internal public class PluginUtils extends Object
Common utility methods for plugin generation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Configuration for a plugin parameter.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.micronaut.sourcegen.model.ExpressionDef
    createDefault(io.micronaut.sourcegen.model.TypeDef type, String value)
    A utility method for getting the default value.
    static io.micronaut.sourcegen.model.StatementDef
    executeTaskMethod(io.micronaut.inject.ast.ClassElement source, String methodName, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments)
    A common method for executing the main task executable.
    static io.micronaut.inject.ast.MethodElement
    getTaskExecutable(io.micronaut.inject.ast.ClassElement source)
    Validate and get the method name of the task executable.
    static io.micronaut.sourcegen.model.VariableDef.Local
    instantiateType(io.micronaut.inject.ast.ClassElement element, String name, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments, List<io.micronaut.sourcegen.model.StatementDef> statements)
    Instantiate a type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PluginUtils

      public PluginUtils()
  • Method Details

    • getTaskExecutable

      public static io.micronaut.inject.ast.MethodElement getTaskExecutable(io.micronaut.inject.ast.ClassElement source)
      Validate and get the method name of the task executable.
      Parameters:
      source - The source element annotated with PluginTask.
      Returns:
      The method name
    • instantiateType

      public static io.micronaut.sourcegen.model.VariableDef.Local instantiateType(io.micronaut.inject.ast.ClassElement element, String name, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments, List<io.micronaut.sourcegen.model.StatementDef> statements)
      Instantiate a type.
      Parameters:
      element - The class element
      name - The name to use for the local variable
      arguments - The arguments provided for type creation corresponding to properties
      statements - A mutable statements list
      Returns:
      The local variable representing the instantiated type
    • executeTaskMethod

      public static io.micronaut.sourcegen.model.StatementDef executeTaskMethod(io.micronaut.inject.ast.ClassElement source, String methodName, Map<String,io.micronaut.sourcegen.model.ExpressionDef> arguments)
      A common method for executing the main task executable.
      Parameters:
      source - The source annotated with PluginTask
      methodName - The name of the method annotated with PluginTaskExecutable
      arguments - The prepared arguments for the task by name
      Returns:
      The statements to execute the task method
    • createDefault

      public static io.micronaut.sourcegen.model.ExpressionDef createDefault(io.micronaut.sourcegen.model.TypeDef type, String value)
      A utility method for getting the default value.
      Parameters:
      type - The required type
      value - The default value as string
      Returns:
      The default expression