Class ModelUtils
java.lang.Object
io.micronaut.sourcegen.generator.visitors.ModelUtils
A utility class for working with complex types, like enums and POJOs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record for holding the generated model. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.micronaut.sourcegen.model.ExpressionDefconvertParameterIfRequired(io.micronaut.inject.ast.ClassElement type, String name, List<io.micronaut.sourcegen.model.StatementDef> statements, io.micronaut.sourcegen.model.ExpressionDef paramExpression) Converts a parameter value if required.static io.micronaut.sourcegen.model.TypeDefgetType(io.micronaut.inject.visitor.VisitorContext context, String packageName, io.micronaut.inject.ast.ClassElement element, List<ModelUtils.GeneratedModel> objects) A utility method for getting a parameter type.static booleanisModel(io.micronaut.inject.ast.ClassElement type) Whether the type is a model, in which case it will be copied.static booleanisPOJO(io.micronaut.inject.ast.ClassElement element) Whether it is considered a POJO.
-
Constructor Details
-
ModelUtils
public ModelUtils()
-
-
Method Details
-
getType
public static io.micronaut.sourcegen.model.TypeDef getType(io.micronaut.inject.visitor.VisitorContext context, String packageName, io.micronaut.inject.ast.ClassElement element, List<ModelUtils.GeneratedModel> objects) A utility method for getting a parameter type. Complex types, like enums and POJOs get copied and re-mapped.- Parameters:
context- the ContextpackageName- The package name to use for new created modelselement- The elementobjects- A mutable list that can be extended with new objects- Returns:
- The type
-
convertParameterIfRequired
public static io.micronaut.sourcegen.model.ExpressionDef convertParameterIfRequired(io.micronaut.inject.ast.ClassElement type, String name, List<io.micronaut.sourcegen.model.StatementDef> statements, io.micronaut.sourcegen.model.ExpressionDef paramExpression) Converts a parameter value if required. Conversion is required if the value is a model, so a new type was generated for it instead of the original one.- Parameters:
type- The typename- The name to use for local variablestatements- The modifiable statements to which a local variable may be added if neededparamExpression- The current expression for param- Returns:
- The new expression for param
-
isPOJO
public static boolean isPOJO(io.micronaut.inject.ast.ClassElement element) Whether it is considered a POJO.- Parameters:
element- The type- Returns:
- Whether it is POJO
-
isModel
public static boolean isModel(io.micronaut.inject.ast.ClassElement type) Whether the type is a model, in which case it will be copied.- Parameters:
type- The type- Returns:
- Whether it is a model
-