Package io.jonasg.bob

Annotation Interface Buildable


@Retention(SOURCE) @Target(TYPE) public @interface Buildable
Marks a class to be buildable, which will generate a builder for the class.

The builder will have a build method that will create an instance of the annotated class.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Marks a constructor as buildable.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Specifies the constructor policy to be applied when building an instance of the annotated class.
    List of fields to be excluded to be included in the builder.
    The package name of the generated builder.
    The setterPrefix for the generated setters.
  • Element Details

    • excludeFields

      String[] excludeFields
      List of fields to be excluded to be included in the builder.
      Returns:
      the list of fields to be excluded to be included in the builder.
      Default:
      {}
    • setterPrefix

      String setterPrefix
      The setterPrefix for the generated setters. For example, "with" or "set" Defaults to no setterPrefix.
      Returns:
      the setterPrefix for the generated setters.
      Default:
      ""
    • packageName

      String packageName
      The package name of the generated builder. Defaults to the package of the annotated class.
      Returns:
      the package name of the generated builder
      Default:
      ""
    • constructorPolicy

      ConstructorPolicy constructorPolicy
      Specifies the constructor policy to be applied when building an instance of the annotated class. The policy controls how strictly the builder enforces the setting of fields during object instantiation.

      The default value is ConstructorPolicy.PERMISSIVE, which allows for more flexibility in field initialization, permitting fields to be optionally set with defaults provided for unset fields. Alternatively, setting this to ConstructorPolicy.ENFORCED requires all fields to be explicitly set, otherwise, the builder throws an exception.

      Returns:
      the constructor policy used by the builder
      Default:
      PERMISSIVE