Class Field.Builder

java.lang.Object
be.imgn.gaia.processing.source.Field.Builder
Enclosing class:
Field

public static final class Field.Builder extends Object
A builder of Fields.
  • Method Details

    • addModifiers

      public Field.Builder addModifiers(Modifier... more)
      Adds modifiers.
      Parameters:
      more - the modifiers
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if a modifier is not allowed on a field, is repeated, or conflicts with another one, such as public with private or final with volatile
    • addAnnotation

      public Field.Builder addAnnotation(Annotation annotation)
      Adds a declaration annotation. A type annotation, such as @Nullable, goes on the type instead.
      Parameters:
      annotation - the annotation
      Returns:
      this builder
    • addAnnotation

      public Field.Builder addAnnotation(Class<? extends Annotation> annotation)
      Adds a declaration annotation without members.
      Parameters:
      annotation - the annotation type
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the class is not an annotation type
    • addAnnotation

      public Field.Builder addAnnotation(ClassName annotation)
      Adds an annotation without members.
      Parameters:
      annotation - the annotation type
      Returns:
      this builder
    • addAnnotations

      public Field.Builder addAnnotations(Iterable<Annotation> more)
      Adds annotations.
      Parameters:
      more - the annotations
      Returns:
      this builder
    • addJavadoc

      public Field.Builder addJavadoc(String format, @Nullable Object... args)
      Adds Javadoc text. End each line with \n.
      Parameters:
      format - the text, with placeholders
      args - the arguments of the placeholders
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the format and the arguments do not match
    • addJavadoc

      public Field.Builder addJavadoc(CodeBlock text)
      Adds Javadoc text. End each line with \n.
      Parameters:
      text - the text
      Returns:
      this builder
    • initializer

      public Field.Builder initializer(String format, @Nullable Object... args)
      Sets the initializer.
      Parameters:
      format - the expression after =, with placeholders
      args - the arguments of the placeholders
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the format and the arguments do not match, or the initializer is not balanced
      IllegalStateException - if the initializer is already set
    • initializer

      public Field.Builder initializer(CodeBlock expression)
      Sets the initializer.
      Parameters:
      expression - the expression after =
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the expression is not balanced
      IllegalStateException - if the initializer is already set
    • build

      public Field build()
      Builds the field.
      Returns:
      the field
      Throws:
      IllegalStateException - if the Javadoc is not balanced