Class Schema.Field

java.lang.Object
org.apache.avro.JsonProperties
org.apache.avro.Schema.Field
Enclosing class:
Schema

public static class Schema.Field extends JsonProperties
A field within a record.
  • Field Details

    • NULL_DEFAULT_VALUE

      public static final Object NULL_DEFAULT_VALUE
      For Schema unions with a "null" type as the first entry, this can be used to specify that the default for the union is null.
  • Constructor Details

    • Field

      public Field(Schema.Field field, Schema schema)
      Constructs a new Field instance with the same name, doc, defaultValue, and order as field has with changing the schema to the specified one. It also copies all the props and aliases.
    • Field

      public Field(String name, Schema schema)
    • Field

      public Field(String name, Schema schema, String doc)
    • Field

      public Field(String name, Schema schema, String doc, Object defaultValue)
      Parameters:
      defaultValue - the default value for this field specified using the mapping in JsonProperties
    • Field

      public Field(String name, Schema schema, String doc, Object defaultValue, Schema.Field.Order order)
      Parameters:
      defaultValue - the default value for this field specified using the mapping in JsonProperties
  • Method Details

    • name

      public String name()
    • pos

      public int pos()
      The position of this field within the record.
    • schema

      public Schema schema()
      This field's Schema.
    • doc

      public String doc()
      Field's documentation within the record, if set. May return null.
    • hasDefaultValue

      public boolean hasDefaultValue()
      Returns:
      true if this Field has a default value set. Can be used to determine if a "null" return from defaultVal() is due to that being the default value or just not set.
    • defaultVal

      public Object defaultVal()
      Returns:
      the default value for this field specified using the mapping in JsonProperties
    • order

      public Schema.Field.Order order()
    • addAlias

      public void addAlias(String alias)
    • aliases

      public Set<String> aliases()
      Return the defined aliases as an unmodifiable Set.
    • equals

      public boolean equals(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