Class Field

java.lang.Object
be.imgn.gaia.processing.source.Field

public final class Field extends Object
A field, such as private static final int LIMIT = 10;.

Fields are values: two fields written the same are equal.

  • Method Details

    • of

      public static Field of(TypeName type, String name, Modifier... modifiers)
      Returns a field without initializer.
      Parameters:
      type - the type
      name - the name
      modifiers - the modifiers
      Returns:
      the field
      Throws:
      IllegalArgumentException - if the name is not a valid identifier, or a modifier is not allowed on a field
    • newBuilder

      public static Field.Builder newBuilder(TypeName type, String name, Modifier... modifiers)
      Returns a builder of fields.
      Parameters:
      type - the type
      name - the name
      modifiers - the modifiers
      Returns:
      a new builder
      Throws:
      IllegalArgumentException - if the name is not a valid identifier, or a modifier is not allowed on a field
    • newBuilder

      public static Field.Builder newBuilder(Class<?> type, String name, Modifier... modifiers)
      Returns a builder of fields.
      Parameters:
      type - the type
      name - the name
      modifiers - the modifiers
      Returns:
      a new builder
      Throws:
      IllegalArgumentException - if the name is not a valid identifier, or a modifier is not allowed on a field
    • type

      public TypeName type()
      Returns the type.
      Returns:
      the type
    • name

      public String name()
      Returns the name.
      Returns:
      the name
    • modifiers

      public Set<Modifier> modifiers()
      Returns the modifiers.
      Returns:
      the modifiers
    • annotations

      public List<Annotation> annotations()
      Returns the declaration annotations.
      Returns:
      the annotations, in order
    • javadoc

      public CodeBlock javadoc()
      Returns the Javadoc.
      Returns:
      the Javadoc text, empty if there is none
    • initializer

      public CodeBlock initializer()
      Returns the initializer.
      Returns:
      the expression after =, empty if there is none
    • toBuilder

      public Field.Builder toBuilder()
      Returns a builder that starts with this field.
      Returns:
      a new builder
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object