Class ConnectSchema

  • All Implemented Interfaces:
    Schema

    public class ConnectSchema
    extends Object
    implements Schema
    • Constructor Detail

      • 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

        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 Detail

      • type

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

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

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

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

        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

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

        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

        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 struct.
        Specified by:
        fields in interface Schema
        Returns:
        the list of fields for this Schema
      • field

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

        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

        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

        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

        public static void validateValue​(String name,
                                         Schema schema,
                                         Object value)
      • validateValue

        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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • schemaType

        public static Schema.Type schemaType​(Class<?> klass)
        Get the Schema.Type associated with the given class.
        Parameters:
        klass - the Class to
        Returns:
        the corresponding type, or null if there is no matching type