Package org.apache.avro

# 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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`Schema.Field.Order`
How values of this field should be ordered when sorting records.

## Nested classes/interfaces inherited from class org.apache.avro.JsonProperties

`JsonProperties.Null`

## Field Summary

Fields
Modifier and Type
Field
Description
`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.

### Fields inherited from class org.apache.avro.JsonProperties

`NULL_VALUE`

## Constructor Summary

Constructors
Constructor
Description
`Field(String name, Schema schema)`
`Field(String name, Schema schema, String doc)`
`Field(String name, Schema schema, String doc, Object defaultValue)`
`Field(String name, Schema schema, String doc, Object defaultValue, Schema.Field.Order order)`
`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.

## Method Summary

Modifier and Type
Method
Description
`void`
`addAlias(String alias)`
`Set<String>`
`aliases()`
Return the defined aliases as an unmodifiable Set.
`Object`
`defaultVal()`
`String`
`doc()`
Field's documentation within the record, if set.
`boolean`
`equals(Object other)`
`boolean`
`hasDefaultValue()`
`int`
`hashCode()`
`String`
`name()`
`Schema.Field.Order`
`order()`
`int`
`pos()`
The position of this field within the record.
`Schema`
`schema()`
This field's `Schema`.
`String`
`toString()`

### Methods inherited from class org.apache.avro.JsonProperties

`addAllProps, addProp, addProp, forEachProperty, getObjectProp, getObjectProp, getObjectProps, getProp, hasProps, propsContainsKey, putAll`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## 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`