Class JavaPoetUtils
java.lang.Object
nl.datasteel.crudcraft.codegen.util.JavaPoetUtils
Helper methods around JavaPoet.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addFieldWithAccessors
(com.squareup.javapoet.TypeSpec.Builder builder, String name, com.squareup.javapoet.TypeName type, List<com.squareup.javapoet.AnnotationSpec> validations, com.squareup.javapoet.AnnotationSpec enumSchema, com.squareup.javapoet.AnnotationSpec fieldSecurity) Adds a private field with standard getter and setter methods.static void
addFieldWithGetter
(com.squareup.javapoet.TypeSpec.Builder builder, String name, com.squareup.javapoet.TypeName type, List<com.squareup.javapoet.AnnotationSpec> validations, com.squareup.javapoet.AnnotationSpec enumSchema, com.squareup.javapoet.AnnotationSpec fieldSecurity) Adds a private final field with a standard getter method.static com.squareup.javapoet.ClassName
getClassName
(String pkg, String simple) Creates aClassName
from a package and simple name.static com.squareup.javapoet.ParameterizedTypeName
getListOf
(com.squareup.javapoet.TypeName type) Returns aParameterizedTypeName
representing aList
of the given type.
-
Method Details
-
getClassName
Creates aClassName
from a package and simple name.- Parameters:
pkg
- package namesimple
- simple class name- Returns:
- a ClassName instance
-
getListOf
public static com.squareup.javapoet.ParameterizedTypeName getListOf(com.squareup.javapoet.TypeName type) Returns aParameterizedTypeName
representing aList
of the given type.- Parameters:
type
- the contained type- Returns:
- a parameterized List type
-
addFieldWithAccessors
public static void addFieldWithAccessors(com.squareup.javapoet.TypeSpec.Builder builder, String name, com.squareup.javapoet.TypeName type, List<com.squareup.javapoet.AnnotationSpec> validations, com.squareup.javapoet.AnnotationSpec enumSchema, com.squareup.javapoet.AnnotationSpec fieldSecurity) Adds a private field with standard getter and setter methods. Optionally applies validation, enum schema and security annotations.- Parameters:
builder
- theTypeSpec.Builder
to add toname
- field nametype
- field typevalidations
- annotations to add directly on the fieldenumSchema
- optional@Schema(allowableValues="...")
fieldSecurity
- optional field security annotation
-
addFieldWithGetter
public static void addFieldWithGetter(com.squareup.javapoet.TypeSpec.Builder builder, String name, com.squareup.javapoet.TypeName type, List<com.squareup.javapoet.AnnotationSpec> validations, com.squareup.javapoet.AnnotationSpec enumSchema, com.squareup.javapoet.AnnotationSpec fieldSecurity) Adds a private final field with a standard getter method. Optionally applies validation, enum schema and security annotations.- Parameters:
builder
- theTypeSpec.Builder
to add toname
- field nametype
- field typevalidations
- annotations to add directly on the fieldenumSchema
- optional@Schema(allowableValues="...")
fieldSecurity
- optional field security annotation
-