Class ConnectSchema

java.lang.Object
org.apache.kafka.connect.data.ConnectSchema
All Implemented Interfaces:
Schema

public class ConnectSchema extends Object implements Schema
  • Constructor Details Link icon

    • ConnectSchema Link icon

      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, preferring SchemaBuilder instead.
    • ConnectSchema Link icon

      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 Link icon

      public ConnectSchema(Schema.Type type)
      Construct a default schema for a primitive type. The schema is required, has no default value, name, version, or documentation.
  • Method Details Link icon

    • type Link icon

      public Schema.Type type()
      Specified by:
      type in interface Schema
      Returns:
      the type of this schema
    • isOptional Link icon

      public boolean isOptional()
      Specified by:
      isOptional in interface Schema
      Returns:
      true if this field is optional, false otherwise
    • defaultValue Link icon

      public Object defaultValue()
      Specified by:
      defaultValue in interface Schema
      Returns:
      the default value for this schema
    • name Link icon

      public String name()
      Specified by:
      name in interface Schema
      Returns:
      the name of this schema
    • version Link icon

      public Integer 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.
      Specified by:
      version in interface Schema
      Returns:
      the version of this schema
    • doc Link icon

      public String doc()
      Specified by:
      doc in interface Schema
      Returns:
      the documentation for this schema
    • parameters Link icon

      public Map<String,String> parameters()
      Description copied from interface: Schema
      Get a map of schema parameters.
      Specified by:
      parameters in interface Schema
      Returns:
      Map containing parameters for this schema, or null if there are no parameters
    • fields Link icon

      public List<Field> fields()
      Description copied from interface: Schema
      Get the list of Fields for this Schema. Throws a DataException if this schema is not a Schema.Type.STRUCT.
      Specified by:
      fields in interface Schema
      Returns:
      the list of fields for this Schema
    • field Link icon

      public Field field(String fieldName)
      Description copied from interface: Schema
      Get a Field for this Schema by name. Throws a DataException if this schema is not a Schema.Type.STRUCT.
      Specified by:
      field in interface Schema
      Parameters:
      fieldName - the name of the field to look up
      Returns:
      the Field object for the specified field, or null if there is no field with the given name
    • keySchema Link icon

      public Schema keySchema()
      Description copied from interface: Schema
      Get the key schema for this map schema. Throws a DataException if this schema is not a map.
      Specified by:
      keySchema in interface Schema
      Returns:
      the key schema
    • valueSchema Link icon

      public Schema valueSchema()
      Description copied from interface: Schema
      Get the value schema for this map or array schema. Throws a DataException if this schema is not a map or array.
      Specified by:
      valueSchema in interface Schema
      Returns:
      the value schema
    • validateValue Link icon

      public static void validateValue(Schema schema, Object value)
      Validate that the value can be used with the schema, i.e. that its type matches the schema type and nullability requirements. Throws a DataException if the value is invalid.
      Parameters:
      schema - Schema to test
      value - value to test
    • validateValue Link icon

      public static void validateValue(String field, Schema schema, Object value)
    • validateValue Link icon

      public void validateValue(Object value)
      Validate that the value can be used for this schema, i.e. that its type matches the schema type and optional requirements. Throws a DataException if the value is invalid.
      Parameters:
      value - the value to validate
    • schema Link icon

      public ConnectSchema schema()
      Description copied from interface: Schema
      Return a concrete instance of the Schema
      Specified by:
      schema in interface Schema
      Returns:
      the Schema
    • equals Link icon

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • schemaType Link icon

      public static Schema.Type schemaType(Class<?> klass)
      Get the Schema.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