Package org.apache.kafka.connect.data
Class Struct
java.lang.Object
org.apache.kafka.connect.data.Struct
     A structured record containing a set of named fields with values, each field using an independent Schema.
     Struct objects must specify a complete Schema up front, and only fields specified in the Schema may be set.
 
     The Struct's put(String, Object) method returns the Struct itself to provide a fluent API for constructing
     complete objects:
     
         Schema schema = SchemaBuilder.struct().name("com.example.Person")
             .field("name", Schema.STRING_SCHEMA).field("age", Schema.INT32_SCHEMA).build()
         Struct struct = new Struct(schema).put("name", "Bobby McGee").put("age", 21)
     
 - 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanGet the value of a field, returning the default value if no value has been set yet and a default value is specified in the field's schema.Get the value of a field, returning the default value if no value has been set yet and a default value is specified in the field's schema.<T> List<T>Equivalent to callingget(String)and casting the result to a List.getBoolean(String fieldName) Equivalent to callingget(String)and casting the result to a Boolean.byte[]Equivalent to callingget(String)and casting the result to a byte[].getFloat32(String fieldName) Equivalent to callingget(String)and casting the result to a Float.getFloat64(String fieldName) Equivalent to callingget(String)and casting the result to a Double.Equivalent to callingget(String)and casting the result to a Short.Equivalent to callingget(String)and casting the result to a Integer.Equivalent to callingget(String)and casting the result to a Long.Equivalent to callingget(String)and casting the result to a Byte.<K,V> Map<K, V> Equivalent to callingget(String)and casting the result to a Map.Equivalent to callingget(String)and casting the result to a String.Equivalent to callingget(String)and casting the result to a Struct.getWithoutDefault(String fieldName) Get the underlying raw value for the field without accounting for default values.inthashCode()Set the value of a field.Set the value of a field.schema()Get the schema for this Struct.toString()voidvalidate()Validates that this struct has filled in all the necessary data with valid values.
- 
Constructor Details
- 
Method Details- 
schemaGet the schema for this Struct.- Returns:
- the Struct's schema
 
- 
getGet the value of a field, returning the default value if no value has been set yet and a default value is specified in the field's schema. Because this handles fields of all types, the value is returned as anObjectand must be cast to a more specific type.- Parameters:
- fieldName- the field name to lookup
- Returns:
- the value for the field
 
- 
getGet the value of a field, returning the default value if no value has been set yet and a default value is specified in the field's schema. Because this handles fields of all types, the value is returned as anObjectand must be cast to a more specific type.- Parameters:
- field- the field to lookup
- Returns:
- the value for the field
 
- 
getWithoutDefaultGet the underlying raw value for the field without accounting for default values.- Parameters:
- fieldName- the field to get the value of
- Returns:
- the raw value
 
- 
getInt8Equivalent to callingget(String)and casting the result to a Byte.
- 
getInt16Equivalent to callingget(String)and casting the result to a Short.
- 
getInt32Equivalent to callingget(String)and casting the result to a Integer.
- 
getInt64Equivalent to callingget(String)and casting the result to a Long.
- 
getFloat32Equivalent to callingget(String)and casting the result to a Float.
- 
getFloat64Equivalent to callingget(String)and casting the result to a Double.
- 
getBooleanEquivalent to callingget(String)and casting the result to a Boolean.
- 
getStringEquivalent to callingget(String)and casting the result to a String.
- 
getBytesEquivalent to callingget(String)and casting the result to a byte[].
- 
getArrayEquivalent to callingget(String)and casting the result to a List.
- 
getMapEquivalent to callingget(String)and casting the result to a Map.
- 
getStructEquivalent to callingget(String)and casting the result to a Struct.
- 
putSet the value of a field. Validates the value, throwing aDataExceptionif it does not match the field'sSchema.- Parameters:
- fieldName- the name of the field to set
- value- the value of the field
- Returns:
- the Struct, to allow chaining of put(String, Object)calls
 
- 
putSet the value of a field. Validates the value, throwing aDataExceptionif it does not match the field'sSchema.- Parameters:
- field- the field to set
- value- the value of the field
- Returns:
- the Struct, to allow chaining of put(String, Object)calls
 
- 
validatepublic void validate()Validates that this struct has filled in all the necessary data with valid values. For required fields without defaults, this validates that a value has been set and has matching types/schemas. If any validation fails, throws a DataException.
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
 
-