Interface SchemaAdapter


  • public interface SchemaAdapter
    Try to adapt the {@param datum} to the {@param expectedSchema}. The following steps are followed: 1. If the schema type doesn't allow for adaptation, return the same value that was passed in input. 2. If the schema type allows for adaptation, then 2a. If the value doesn't specify a value for any field, the default value is used 2b. If a field is mandatory, but no default values are specified, then an Exception is thrown
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object adapt​(org.apache.avro.Schema expectedSchema, java.lang.Object datum)  
      static java.lang.Object adaptToSchema​(org.apache.avro.Schema expectedSchema, java.lang.Object datum)
      Checks if it is possible for some value to be modified to adapt to the provided schema type.
      static SchemaAdapter getSchemaAdapter​(org.apache.avro.Schema.Type expectedSchemaType)
      Checks if it is possible for some value to be modified to adapt to the provided schema type.
    • Method Detail

      • adapt

        java.lang.Object adapt​(org.apache.avro.Schema expectedSchema,
                               java.lang.Object datum)
      • getSchemaAdapter

        static SchemaAdapter getSchemaAdapter​(org.apache.avro.Schema.Type expectedSchemaType)
        Checks if it is possible for some value to be modified to adapt to the provided schema type.
        Parameters:
        expectedSchemaType - The type Schema.Type that the value needs to be adapted to.
        Returns:
        true if a value can be modified to adapt to the provided schema type; false otherwise.
      • adaptToSchema

        static java.lang.Object adaptToSchema​(org.apache.avro.Schema expectedSchema,
                                              java.lang.Object datum)
        Checks if it is possible for some value to be modified to adapt to the provided schema type.
        Parameters:
        expectedSchemaType - The type Schema.Type that the value needs to be adapted to.
        Returns:
        true if a value can be modified to adapt to the provided schema type; false otherwise.