Package org.apache.avro
Class SchemaBuilder.BaseTypeBuilder<R>
java.lang.Object
org.apache.avro.SchemaBuilder.BaseTypeBuilder<R>
- Direct Known Subclasses:
SchemaBuilder.TypeBuilder
- Enclosing class:
SchemaBuilder
A common API for building types within a context. BaseTypeBuilder can build
all types other than Unions. A naming context provides a default namespace and allows for previously
defined named types to be referenced from
A completion context representing the scope that the builder was created
in. A builder created in a nested context (for example,
SchemaBuilder.TypeBuilder
can additionally build
Unions.
The builder has two contexts:
type(String)
SchemaBuilder.MapBuilder.values()
will have a completion context assigned by the
SchemaBuilder.MapBuilder
-
Method Summary
Modifier and TypeMethodDescriptionfinal SchemaBuilder.ArrayBuilder
<R> array()
Build an Avro array type Example usage:final SchemaBuilder.BooleanBuilder
<R> Build a boolean type that can set custom properties.final R
A plain boolean type without custom properties.final SchemaBuilder.BytesBuilder
<R> Build a bytes type that can set custom properties.final R
A plain bytes type without custom properties.final SchemaBuilder.DoubleBuilder
<R> Build a double type that can set custom properties.final R
A plain double type without custom properties.final SchemaBuilder.EnumBuilder
<R> enumeration
(String name) Build an Avro enum type.final SchemaBuilder.FixedBuilder
<R> Build an Avro fixed type.final SchemaBuilder.FloatBuilder
<R> Build a float type that can set custom properties.final R
A plain float type without custom properties.final SchemaBuilder.IntBuilder
<R> Build an int type that can set custom properties.final R
intType()
A plain int type without custom properties.final SchemaBuilder.LongBuilder
<R> Build a long type that can set custom properties.final R
longType()
A plain long type without custom properties.final SchemaBuilder.MapBuilder
<R> map()
Build an Avro map type Example usage:protected SchemaBuilder.BaseTypeBuilder
<R> nullable()
A shortcut for building a union of a type and null.final SchemaBuilder.NullBuilder
<R> Build a null type that can set custom properties.final R
nullType()
A plain null type without custom properties.final SchemaBuilder.RecordBuilder
<R> Build an Avro record type.final SchemaBuilder.StringBldr
<R> Build a string type that can set custom properties.final R
A plain string type without custom properties.final R
Look up the type by name.final R
Look up the type by name and namespace.final R
Use the schema provided as the type.unionOf()
Build an Avro union schema type.
-
Method Details
-
type
Use the schema provided as the type. -
type
Look up the type by name. This type must be previously defined in the context of this builder. The name may be fully qualified or a short name. If it is a short name, the default namespace of the current context will additionally be searched. -
type
Look up the type by name and namespace. This type must be previously defined in the context of this builder. The name may be fully qualified or a short name. If it is a fully qualified name, the namespace provided is ignored. If it is a short name, the namespace provided is used if not null, else the default namespace of the current context will be used. -
booleanType
A plain boolean type without custom properties. This is equivalent to:booleanBuilder().endBoolean();
-
booleanBuilder
Build a boolean type that can set custom properties. If custom properties are not needed it is simpler to usebooleanType()
. -
intType
A plain int type without custom properties. This is equivalent to:intBuilder().endInt();
-
intBuilder
Build an int type that can set custom properties. If custom properties are not needed it is simpler to useintType()
. -
longType
A plain long type without custom properties. This is equivalent to:longBuilder().endLong();
-
longBuilder
Build a long type that can set custom properties. If custom properties are not needed it is simpler to uselongType()
. -
floatType
A plain float type without custom properties. This is equivalent to:floatBuilder().endFloat();
-
floatBuilder
Build a float type that can set custom properties. If custom properties are not needed it is simpler to usefloatType()
. -
doubleType
A plain double type without custom properties. This is equivalent to:doubleBuilder().endDouble();
-
doubleBuilder
Build a double type that can set custom properties. If custom properties are not needed it is simpler to usedoubleType()
. -
stringType
A plain string type without custom properties. This is equivalent to:stringBuilder().endString();
-
stringBuilder
Build a string type that can set custom properties. If custom properties are not needed it is simpler to usestringType()
. -
bytesType
A plain bytes type without custom properties. This is equivalent to:bytesBuilder().endBytes();
-
bytesBuilder
Build a bytes type that can set custom properties. If custom properties are not needed it is simpler to usebytesType()
. -
nullType
A plain null type without custom properties. This is equivalent to:nullBuilder().endNull();
-
nullBuilder
Build a null type that can set custom properties. If custom properties are not needed it is simpler to usenullType()
. -
map
Build an Avro map type Example usage:map().values().intType()
Equivalent to Avro JSON Schema:{"type":"map", "values":"int"}
-
array
Build an Avro array type Example usage:array().items().longType()
Equivalent to Avro JSON Schema:{"type":"array", "values":"long"}
-
fixed
Build an Avro fixed type. Example usage:fixed("com.foo.IPv4").size(4)
Equivalent to Avro JSON Schema:{"type":"fixed", "name":"com.foo.IPv4", "size":4}
-
enumeration
Build an Avro enum type. Example usage:enumeration("Suits").namespace("org.cards").doc("card suit names").defaultSymbol("HEART").symbols("HEART", "SPADE", "DIAMOND", "CLUB")
Equivalent to Avro JSON Schema:{"type":"enum", "name":"Suits", "namespace":"org.cards", "doc":"card suit names", "symbols":[ "HEART", "SPADE", "DIAMOND", "CLUB"], "default":"HEART"}
-
record
Build an Avro record type. Example usage:record("com.foo.Foo").fields().name("field1").typeInt().intDefault(1).name("field2").typeString().noDefault() .name("field3").optional().typeFixed("FooFixed").size(4).endRecord()
Equivalent to Avro JSON Schema:{"type":"record", "name":"com.foo.Foo", "fields": [ {"name":"field1", "type":"int", "default":1}, {"name":"field2", "type":"string"}, {"name":"field3", "type":[ null, {"type":"fixed", "name":"FooFixed", "size":4} ]} ]}
-
unionOf
Build an Avro union schema type. Example usage:unionOf().stringType().and().bytesType().endUnion()
-
nullable
A shortcut for building a union of a type and null. For example, the code snippets below are equivalent:nullable().booleanType()
unionOf().booleanType().and().nullType().endUnion()
-