Class ConnectHeaders

java.lang.Object
org.apache.kafka.connect.header.ConnectHeaders
All Implemented Interfaces:
Iterable<Header>, Headers

public class ConnectHeaders
extends Object
implements Headers
A basic Headers implementation.
  • Constructor Details

    • ConnectHeaders

      public ConnectHeaders()
    • ConnectHeaders

      public ConnectHeaders​(Iterable<Header> original)
  • Method Details

    • size

      public int size()
      Description copied from interface: Headers
      Get the number of headers in this object.
      Specified by:
      size in interface Headers
      Returns:
      the number of headers; never negative
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Headers
      Determine whether this object has no headers.
      Specified by:
      isEmpty in interface Headers
      Returns:
      true if there are no headers, or false if there is at least one header
    • clear

      public Headers clear()
      Description copied from interface: Headers
      Removes all headers from this object.
      Specified by:
      clear in interface Headers
      Returns:
      this object to facilitate chaining multiple methods; never null
    • add

      public Headers add​(Header header)
      Description copied from interface: Headers
      Add the given Header to this collection.
      Specified by:
      add in interface Headers
      Parameters:
      header - the header; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addWithoutValidating

      protected Headers addWithoutValidating​(String key, Object value, Schema schema)
    • add

      public Headers add​(String key, SchemaAndValue schemaAndValue)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      add in interface Headers
      Parameters:
      key - the header's key; may not be null
      schemaAndValue - the SchemaAndValue for the header; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • add

      public Headers add​(String key, Object value, Schema schema)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      add in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      schema - the schema for the header's value; may not be null if the value is not null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addString

      public Headers addString​(String key, String value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addString in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addBytes

      public Headers addBytes​(String key, byte[] value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addBytes in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addBoolean

      public Headers addBoolean​(String key, boolean value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addBoolean in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addByte

      public Headers addByte​(String key, byte value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addByte in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addShort

      public Headers addShort​(String key, short value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addShort in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addInt

      public Headers addInt​(String key, int value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addInt in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addLong

      public Headers addLong​(String key, long value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addLong in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addFloat

      public Headers addFloat​(String key, float value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addFloat in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addDouble

      public Headers addDouble​(String key, double value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addDouble in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addList

      public Headers addList​(String key, List<?> value, Schema schema)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addList in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      schema - the schema describing the list value; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addMap

      public Headers addMap​(String key, Map<?,​?> value, Schema schema)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addMap in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      schema - the schema describing the map value; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addStruct

      public Headers addStruct​(String key, Struct value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and value.
      Specified by:
      addStruct in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addDecimal

      public Headers addDecimal​(String key, BigDecimal value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and Decimal value.
      Specified by:
      addDecimal in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's Decimal value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addDate

      public Headers addDate​(String key, Date value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and Date value.
      Specified by:
      addDate in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's Date value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addTime

      public Headers addTime​(String key, Date value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and Time value.
      Specified by:
      addTime in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's Time value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • addTimestamp

      public Headers addTimestamp​(String key, Date value)
      Description copied from interface: Headers
      Add to this collection a Header with the given key and Timestamp value.
      Specified by:
      addTimestamp in interface Headers
      Parameters:
      key - the header's key; may not be null
      value - the header's Timestamp value; may be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • lastWithName

      public Header lastWithName​(String key)
      Description copied from interface: Headers
      Return the last Header with the specified key.
      Specified by:
      lastWithName in interface Headers
      Parameters:
      key - the key for the header; may not be null
      Returns:
      the last Header, or null if there are no headers with the specified key
    • allWithName

      public Iterator<Header> allWithName​(String key)
      Description copied from interface: Headers
      Get the collection of Header objects whose keys all match the specified key.
      Specified by:
      allWithName in interface Headers
      Parameters:
      key - the key; may not be null
      Returns:
      the iterator over headers with the specified key; may be null if there are no headers with the specified key
    • iterator

      public Iterator<Header> iterator()
      Specified by:
      iterator in interface Iterable<Header>
    • remove

      public Headers remove​(String key)
      Description copied from interface: Headers
      Removes all Header objects whose key matches the specified key.
      Specified by:
      remove in interface Headers
      Parameters:
      key - the key; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • retainLatest

      public Headers retainLatest()
      Description copied from interface: Headers
      Removes all but the last Header object with each key.
      Specified by:
      retainLatest in interface Headers
      Returns:
      this object to facilitate chaining multiple methods; never null
    • retainLatest

      public Headers retainLatest​(String key)
      Description copied from interface: Headers
      Removes all but the latest Header objects whose key matches the specified key.
      Specified by:
      retainLatest in interface Headers
      Parameters:
      key - the key; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • apply

      public Headers apply​(String key, Headers.HeaderTransform transform)
      Description copied from interface: Headers
      Get all Headers with the given key, apply the transform to each and store the result in place of the original.
      Specified by:
      apply in interface Headers
      Parameters:
      key - the header's key; may not be null
      transform - the transform to apply; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • apply

      public Headers apply​(Headers.HeaderTransform transform)
      Description copied from interface: Headers
      Get all Headers, apply the transform to each and store the result in place of the original.
      Specified by:
      apply in interface Headers
      Parameters:
      transform - the transform to apply; may not be null
      Returns:
      this object to facilitate chaining multiple methods; never null
    • hashCode

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

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • duplicate

      public ConnectHeaders duplicate()
      Description copied from interface: Headers
      Create a copy of this Headers object. The new copy will contain all of the same Header objects as this object.
      Specified by:
      duplicate in interface Headers
      Returns:
      the copy; never null