test_class.declarator: MAP_INT_STRING_SCHEMA = SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA).build()
test_class.modifier: private static final
test_class.original_string: private static final Schema MAP_INT_STRING_SCHEMA = SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA).build();
test_class.type: Schema
test_class.var_name: MAP_INT_STRING_SCHEMA
test_class.declarator: FLAT_STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("field", Schema.INT32_SCHEMA)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Schema FLAT_STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("field", Schema.INT32_SCHEMA)
              .build();
test_class.type: Schema
test_class.var_name: FLAT_STRUCT_SCHEMA
test_class.declarator: STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("first", Schema.INT32_SCHEMA)
              .field("second", Schema.STRING_SCHEMA)
              .field("array", SchemaBuilder.array(Schema.INT32_SCHEMA).build())
              .field("map", SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA).build())
              .field("nested", FLAT_STRUCT_SCHEMA)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Schema STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("first", Schema.INT32_SCHEMA)
              .field("second", Schema.STRING_SCHEMA)
              .field("array", SchemaBuilder.array(Schema.INT32_SCHEMA).build())
              .field("map", SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA).build())
              .field("nested", FLAT_STRUCT_SCHEMA)
              .build();
test_class.type: Schema
test_class.var_name: STRUCT_SCHEMA
test_class.declarator: PARENT_STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("nested", FLAT_STRUCT_SCHEMA)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Schema PARENT_STRUCT_SCHEMA = SchemaBuilder.struct()
              .field("nested", FLAT_STRUCT_SCHEMA)
              .build();
test_class.type: Schema
test_class.var_name: PARENT_STRUCT_SCHEMA
test_class.file: connect/api/src/test/java/org/apache/kafka/connect/data/ConnectSchemaTest.java
test_class.identifier: ConnectSchemaTest
test_case.body: @Test
      public void testValidateValueMatchingType() {
          ConnectSchema.validateValue(Schema.INT8_SCHEMA, (byte) 1);
          ConnectSchema.validateValue(Schema.INT16_SCHEMA, (short) 1);
          ConnectSchema.validateValue(Schema.INT32_SCHEMA, 1);
          ConnectSchema.validateValue(Schema.INT64_SCHEMA, (long) 1);
          ConnectSchema.validateValue(Schema.FLOAT32_SCHEMA, 1.f);
          ConnectSchema.validateValue(Schema.FLOAT64_SCHEMA, 1.);
          ConnectSchema.validateValue(Schema.BOOLEAN_SCHEMA, true);
          ConnectSchema.validateValue(Schema.STRING_SCHEMA, "a string");
          ConnectSchema.validateValue(Schema.BYTES_SCHEMA, "a byte array".getBytes());
          ConnectSchema.validateValue(Schema.BYTES_SCHEMA, ByteBuffer.wrap("a byte array".getBytes()));
          ConnectSchema.validateValue(SchemaBuilder.array(Schema.INT32_SCHEMA).build(), Arrays.asList(1, 2, 3));
          ConnectSchema.validateValue(
                  SchemaBuilder.map(Schema.INT32_SCHEMA, Schema.STRING_SCHEMA).build(),
                  Collections.singletonMap(1, "value")
          );
          // Struct tests the basic struct layout + complex field types + nested structs
          Struct structValue = new Struct(STRUCT_SCHEMA)
                  .put("first", 1)
                  .put("second", "foo")
                  .put("array", Arrays.asList(1, 2, 3))
                  .put("map", Collections.singletonMap(1, "value"))
                  .put("nested", new Struct(FLAT_STRUCT_SCHEMA).put("field", 12));
          ConnectSchema.validateValue(STRUCT_SCHEMA, structValue);
      }
test_case.class_method_signature: ConnectSchemaTest.testValidateValueMatchingType()
test_case.full_signature: @Test public void testValidateValueMatchingType()
test_case.identifier: testValidateValueMatchingType
test_case.invocations: validateValue validateValue validateValue validateValue validateValue validateValue validateValue validateValue validateValue getBytes validateValue wrap getBytes validateValue build array asList validateValue build map singletonMap put put put put put asList singletonMap put validateValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testValidateValueMatchingType()
focal_class.declarator: SCHEMA_TYPE_CLASSES = new HashMap<>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<Type, List<Class>> SCHEMA_TYPE_CLASSES = new HashMap<>();
focal_class.type: Map<Type, List<Class>>
focal_class.var_name: SCHEMA_TYPE_CLASSES
focal_class.declarator: LOGICAL_TYPE_CLASSES = new HashMap<>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, List<Class>> LOGICAL_TYPE_CLASSES = new HashMap<>();
focal_class.type: Map<String, List<Class>>
focal_class.var_name: LOGICAL_TYPE_CLASSES
focal_class.declarator: JAVA_CLASS_SCHEMA_TYPES = new HashMap<>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<Class<?>, Type> JAVA_CLASS_SCHEMA_TYPES = new HashMap<>();
focal_class.type: Map<Class<?>, Type>
focal_class.var_name: JAVA_CLASS_SCHEMA_TYPES
focal_class.declarator: type
focal_class.modifier: private final
focal_class.original_string: private final Type type;
focal_class.type: Type
focal_class.var_name: type
focal_class.declarator: optional
focal_class.modifier: private final
focal_class.original_string: private final boolean optional;
focal_class.type: boolean
focal_class.var_name: optional
focal_class.declarator: defaultValue
focal_class.modifier: private final
focal_class.original_string: private final Object defaultValue;
focal_class.type: Object
focal_class.var_name: defaultValue
focal_class.declarator: fields
focal_class.modifier: private final
focal_class.original_string: private final List<Field> fields;
focal_class.type: List<Field>
focal_class.var_name: fields
focal_class.declarator: fieldsByName
focal_class.modifier: private final
focal_class.original_string: private final Map<String, Field> fieldsByName;
focal_class.type: Map<String, Field>
focal_class.var_name: fieldsByName
focal_class.declarator: keySchema
focal_class.modifier: private final
focal_class.original_string: private final Schema keySchema;
focal_class.type: Schema
focal_class.var_name: keySchema
focal_class.declarator: valueSchema
focal_class.modifier: private final
focal_class.original_string: private final Schema valueSchema;
focal_class.type: Schema
focal_class.var_name: valueSchema
focal_class.declarator: name
focal_class.modifier: private final
focal_class.original_string: private final String name;
focal_class.type: String
focal_class.var_name: name
focal_class.declarator: version
focal_class.modifier: private final
focal_class.original_string: private final Integer version;
focal_class.type: Integer
focal_class.var_name: version
focal_class.declarator: doc
focal_class.modifier: private final
focal_class.original_string: private final String doc;
focal_class.type: String
focal_class.var_name: doc
focal_class.declarator: parameters
focal_class.modifier: private final
focal_class.original_string: private final Map<String, String> parameters;
focal_class.type: Map<String, String>
focal_class.var_name: parameters
focal_class.file: connect/api/src/main/java/org/apache/kafka/connect/data/ConnectSchema.java
focal_class.identifier: ConnectSchema
focal_class.interfaces: implements Schema
focal_class.class_method_signature: ConnectSchema.ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema)
focal_class.full_signature: public  ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema)
focal_class.identifier: ConnectSchema
focal_class.modifiers: public
focal_class.parameters: (Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema)
focal_class.signature:  ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc, Map<String, String> parameters, List<Field> fields, Schema keySchema, Schema valueSchema)
focal_class.class_method_signature: ConnectSchema.ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc)
focal_class.full_signature: public  ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc)
focal_class.identifier: ConnectSchema
focal_class.modifiers: public
focal_class.parameters: (Type type, boolean optional, Object defaultValue, String name, Integer version, String doc)
focal_class.signature:  ConnectSchema(Type type, boolean optional, Object defaultValue, String name, Integer version, String doc)
focal_class.class_method_signature: ConnectSchema.ConnectSchema(Type type)
focal_class.full_signature: public  ConnectSchema(Type type)
focal_class.identifier: ConnectSchema
focal_class.modifiers: public
focal_class.parameters: (Type type)
focal_class.signature:  ConnectSchema(Type type)
focal_class.class_method_signature: ConnectSchema.type()
focal_class.full_signature: @Override public Type type()
focal_class.identifier: type
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Type
focal_class.signature: Type type()
focal_class.class_method_signature: ConnectSchema.isOptional()
focal_class.full_signature: @Override public boolean isOptional()
focal_class.identifier: isOptional
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isOptional()
focal_class.class_method_signature: ConnectSchema.defaultValue()
focal_class.full_signature: @Override public Object defaultValue()
focal_class.identifier: defaultValue
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Object
focal_class.signature: Object defaultValue()
focal_class.class_method_signature: ConnectSchema.name()
focal_class.full_signature: @Override public String name()
focal_class.identifier: name
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String name()
focal_class.class_method_signature: ConnectSchema.version()
focal_class.full_signature: @Override public Integer version()
focal_class.identifier: version
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Integer
focal_class.signature: Integer version()
focal_class.class_method_signature: ConnectSchema.doc()
focal_class.full_signature: @Override public String doc()
focal_class.identifier: doc
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String doc()
focal_class.class_method_signature: ConnectSchema.parameters()
focal_class.full_signature: @Override public Map<String, String> parameters()
focal_class.identifier: parameters
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> parameters()
focal_class.class_method_signature: ConnectSchema.fields()
focal_class.full_signature: @Override public List<Field> fields()
focal_class.identifier: fields
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Field>
focal_class.signature: List<Field> fields()
focal_class.class_method_signature: ConnectSchema.field(String fieldName)
focal_class.full_signature: public Field field(String fieldName)
focal_class.identifier: field
focal_class.modifiers: public
focal_class.parameters: (String fieldName)
focal_class.return: Field
focal_class.signature: Field field(String fieldName)
focal_class.class_method_signature: ConnectSchema.keySchema()
focal_class.full_signature: @Override public Schema keySchema()
focal_class.identifier: keySchema
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Schema
focal_class.signature: Schema keySchema()
focal_class.class_method_signature: ConnectSchema.valueSchema()
focal_class.full_signature: @Override public Schema valueSchema()
focal_class.identifier: valueSchema
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Schema
focal_class.signature: Schema valueSchema()
focal_class.class_method_signature: ConnectSchema.validateValue(Schema schema, Object value)
focal_class.full_signature: public static void validateValue(Schema schema, Object value)
focal_class.identifier: validateValue
focal_class.modifiers: public static
focal_class.parameters: (Schema schema, Object value)
focal_class.return: void
focal_class.signature: void validateValue(Schema schema, Object value)
focal_class.class_method_signature: ConnectSchema.validateValue(Object value)
focal_class.full_signature: public void validateValue(Object value)
focal_class.identifier: validateValue
focal_class.modifiers: public
focal_class.parameters: (Object value)
focal_class.return: void
focal_class.signature: void validateValue(Object value)
focal_class.class_method_signature: ConnectSchema.schema()
focal_class.full_signature: @Override public ConnectSchema schema()
focal_class.identifier: schema
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ConnectSchema
focal_class.signature: ConnectSchema schema()
focal_class.class_method_signature: ConnectSchema.equals(Object o)
focal_class.full_signature: @Override public boolean equals(Object o)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean equals(Object o)
focal_class.class_method_signature: ConnectSchema.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: ConnectSchema.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: ConnectSchema.schemaType(Class<?> klass)
focal_class.full_signature: public static Type schemaType(Class<?> klass)
focal_class.identifier: schemaType
focal_class.modifiers: public static
focal_class.parameters: (Class<?> klass)
focal_class.return: Type
focal_class.signature: Type schemaType(Class<?> klass)
focal_method.body: public static void validateValue(Schema schema, Object value) {
          if (value == null) {
              if (!schema.isOptional())
                  throw new DataException("Invalid value: null used for required field");
              else
                  return;
          }
  
          List<Class> expectedClasses = LOGICAL_TYPE_CLASSES.get(schema.name());
  
          if (expectedClasses == null)
                  expectedClasses = SCHEMA_TYPE_CLASSES.get(schema.type());
  
          if (expectedClasses == null)
              throw new DataException("Invalid Java object for schema type " + schema.type() + ": " + value.getClass());
  
          boolean foundMatch = false;
          for (Class<?> expectedClass : expectedClasses) {
              if (expectedClass.isInstance(value)) {
                  foundMatch = true;
                  break;
              }
          }
          if (!foundMatch)
              throw new DataException("Invalid Java object for schema type " + schema.type() + ": " + value.getClass());
  
          switch (schema.type()) {
              case STRUCT:
                  Struct struct = (Struct) value;
                  if (!struct.schema().equals(schema))
                      throw new DataException("Struct schemas do not match.");
                  struct.validate();
                  break;
              case ARRAY:
                  List<?> array = (List<?>) value;
                  for (Object entry : array)
                      validateValue(schema.valueSchema(), entry);
                  break;
              case MAP:
                  Map<?, ?> map = (Map<?, ?>) value;
                  for (Map.Entry<?, ?> entry : map.entrySet()) {
                      validateValue(schema.keySchema(), entry.getKey());
                      validateValue(schema.valueSchema(), entry.getValue());
                  }
                  break;
          }
      }
focal_method.class_method_signature: ConnectSchema.validateValue(Schema schema, Object value)
focal_method.full_signature: public static void validateValue(Schema schema, Object value)
focal_method.identifier: validateValue
focal_method.invocations: isOptional get name get type type getClass isInstance type getClass type equals schema validate validateValue valueSchema entrySet validateValue keySchema getKey validateValue valueSchema getValue
focal_method.modifiers: public static
focal_method.parameters: (Schema schema, Object value)
focal_method.return: void
focal_method.signature: void validateValue(Schema schema, Object value)