Class JavaPoetUtils

java.lang.Object
nl.datasteel.crudcraft.codegen.util.JavaPoetUtils

public final class JavaPoetUtils extends Object
Helper methods around JavaPoet.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 a ClassName from a package and simple name.
    static com.squareup.javapoet.ParameterizedTypeName
    getListOf(com.squareup.javapoet.TypeName type)
    Returns a ParameterizedTypeName representing a List of the given type.

    Methods inherited from class java.lang.Object

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

    • getClassName

      public static com.squareup.javapoet.ClassName getClassName(String pkg, String simple)
      Creates a ClassName from a package and simple name.
      Parameters:
      pkg - package name
      simple - simple class name
      Returns:
      a ClassName instance
    • getListOf

      public static com.squareup.javapoet.ParameterizedTypeName getListOf(com.squareup.javapoet.TypeName type)
      Returns a ParameterizedTypeName representing a List 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 - the TypeSpec.Builder to add to
      name - field name
      type - field type
      validations - annotations to add directly on the field
      enumSchema - 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 - the TypeSpec.Builder to add to
      name - field name
      type - field type
      validations - annotations to add directly on the field
      enumSchema - optional @Schema(allowableValues="...")
      fieldSecurity - optional field security annotation