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.TypeField 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_SCHEMAConstructor Summary
ConstructorsConstructorDescriptionConnectSchema(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()booleanGet aFieldfor this Schema by name.fields()Get the list of Fields for this Schema.inthashCode()booleanGet the key schema for this map schema.name()Get a map of schema parameters.schema()Return a concrete instance of theSchemastatic Schema.TypeschemaType(Class<?> klass) Get theSchema.Typeassociated with the given class.toString()type()voidvalidateValue(Object value) Validate that the value can be used for this schema, i.e.static voidvalidateValue(String field, Schema schema, Object value) static voidvalidateValue(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, preferringSchemaBuilderinstead.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:
isOptionalin interfaceSchema- Returns:
- true if this field is optional, false otherwise
defaultValue
- Specified by:
defaultValuein interfaceSchema- Returns:
- the default value for this schema
name
version
doc
parameters
fields
Description copied from interface:SchemaGet the list of Fields for this Schema. Throws aDataExceptionif this schema is not aSchema.Type.STRUCT.field
Description copied from interface:SchemaGet aFieldfor this Schema by name. Throws aDataExceptionif this schema is not aSchema.Type.STRUCT.keySchema
Description copied from interface:SchemaGet the key schema for this map schema. Throws aDataExceptionif this schema is not a map.valueSchema
Description copied from interface:SchemaGet the value schema for this map or array schema. Throws aDataExceptionif this schema is not a map or array.- Specified by:
valueSchemain 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 aDataExceptionif 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 aDataExceptionif the value is invalid.- Parameters:
value- the value to validate
schema
equals
hashCode
toString
schemaType
Get theSchema.Typeassociated 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