Package org.apache.kafka.connect.data
Class ConnectSchema
java.lang.Object
org.apache.kafka.connect.data.ConnectSchema
- All Implemented Interfaces:
Schema
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.kafka.connect.data.Schema
Schema.Type
-
Field Summary
Fields inherited from interface org.apache.kafka.connect.data.Schema
BOOLEAN_SCHEMA, BYTES_SCHEMA, FLOAT32_SCHEMA, FLOAT64_SCHEMA, INT16_SCHEMA, INT32_SCHEMA, INT64_SCHEMA, INT8_SCHEMA, OPTIONAL_BOOLEAN_SCHEMA, OPTIONAL_BYTES_SCHEMA, OPTIONAL_FLOAT32_SCHEMA, OPTIONAL_FLOAT64_SCHEMA, OPTIONAL_INT16_SCHEMA, OPTIONAL_INT32_SCHEMA, OPTIONAL_INT64_SCHEMA, OPTIONAL_INT8_SCHEMA, OPTIONAL_STRING_SCHEMA, STRING_SCHEMA
-
Constructor Summary
ConstructorDescriptionConnectSchema
(Schema.Type type) Construct a default schema for a primitive type.ConnectSchema
(Schema.Type type, boolean optional, Object defaultValue, String name, Integer version, String doc) Construct a Schema for a primitive type, setting schema parameters, struct fields, and key and value schemas to null.ConnectSchema
(Schema.Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema) Construct a Schema. -
Method Summary
Modifier and TypeMethodDescriptiondoc()
boolean
Get aField
for this Schema by name.fields()
Get the list of Fields for this Schema.int
hashCode()
boolean
Get the key schema for this map schema.name()
Get a map of schema parameters.schema()
Return a concrete instance of theSchema
static Schema.Type
schemaType
(Class<?> klass) Get theSchema.Type
associated with the given class.toString()
type()
void
validateValue
(Object value) Validate that the value can be used for this schema, i.e.static void
validateValue
(String field, Schema schema, Object value) static void
validateValue
(Schema schema, Object value) Validate that the value can be used with the schema, i.e.Get the value schema for this map or array schema.version()
Get the optional version of the schema.
-
Constructor Details
-
ConnectSchema
public ConnectSchema(Schema.Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema) Construct a Schema. Most users should not construct schemas manually, preferringSchemaBuilder
instead. -
ConnectSchema
public ConnectSchema(Schema.Type type, boolean optional, Object defaultValue, String name, Integer version, String doc) Construct a Schema for a primitive type, setting schema parameters, struct fields, and key and value schemas to null. -
ConnectSchema
Construct a default schema for a primitive type. The schema is required, has no default value, name, version, or documentation.
-
-
Method Details
-
type
-
isOptional
public boolean isOptional()- Specified by:
isOptional
in interfaceSchema
- Returns:
- true if this field is optional, false otherwise
-
defaultValue
- Specified by:
defaultValue
in interfaceSchema
- Returns:
- the default value for this schema
-
name
-
version
Description copied from interface:Schema
Get the optional version of the schema. If a version is included, newer versions must be larger than older ones. -
doc
-
parameters
Description copied from interface:Schema
Get a map of schema parameters.- Specified by:
parameters
in interfaceSchema
- Returns:
- Map containing parameters for this schema, or null if there are no parameters
-
fields
Description copied from interface:Schema
Get the list of Fields for this Schema. Throws aDataException
if this schema is not aSchema.Type.STRUCT
. -
field
Description copied from interface:Schema
Get aField
for this Schema by name. Throws aDataException
if this schema is not aSchema.Type.STRUCT
. -
keySchema
Description copied from interface:Schema
Get the key schema for this map schema. Throws aDataException
if this schema is not a map. -
valueSchema
Description copied from interface:Schema
Get the value schema for this map or array schema. Throws aDataException
if this schema is not a map or array.- Specified by:
valueSchema
in interfaceSchema
- Returns:
- the value schema
-
validateValue
Validate that the value can be used with the schema, i.e. that its type matches the schema type and nullability requirements. Throws aDataException
if the value is invalid.- Parameters:
schema
- Schema to testvalue
- value to test
-
validateValue
-
validateValue
Validate that the value can be used for this schema, i.e. that its type matches the schema type and optional requirements. Throws aDataException
if the value is invalid.- Parameters:
value
- the value to validate
-
schema
Description copied from interface:Schema
Return a concrete instance of theSchema
-
equals
-
hashCode
public int hashCode() -
toString
-
schemaType
Get theSchema.Type
associated with the given class.- Parameters:
klass
- the Class whose associated schema type is to be returned- Returns:
- the corresponding type, or null if there is no matching type
-