Class JavaPoetUtils
java.lang.Object
nl.datasteel.crudcraft.codegen.util.JavaPoetUtils
Helper methods around JavaPoet.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddFieldWithAccessors(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 voidaddFieldWithGetter(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.ClassNamegetClassName(String pkg, String simple) Creates aClassNamefrom a package and simple name.static com.squareup.javapoet.ParameterizedTypeNamegetListOf(com.squareup.javapoet.TypeName type) Returns aParameterizedTypeNamerepresenting aListof the given type.
-
Method Details
-
getClassName
Creates aClassNamefrom 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 aParameterizedTypeNamerepresenting aListof 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.Builderto 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.Builderto add toname- field nametype- field typevalidations- annotations to add directly on the fieldenumSchema- optional@Schema(allowableValues="...")fieldSecurity- optional field security annotation
-