Class Produced<K,V>

java.lang.Object
org.apache.kafka.streams.kstream.Produced<K,V>
Type Parameters:
K - key type
V - value type

public class Produced<K,V> extends Object
This class is used to provide the optional parameters when producing to new topics using KStream.to(String, Produced).
  • Field Details

    • keySerde

      protected Serde<K> keySerde
    • valueSerde

      protected Serde<V> valueSerde
    • partitioner

      protected StreamPartitioner<? super K,? super V> partitioner
    • processorName

      protected String processorName
  • Constructor Details

    • Produced

      protected Produced(Produced<K,V> produced)
  • Method Details

    • with

      public static <K, V> Produced<K,V> with(Serde<K> keySerde, Serde<V> valueSerde)
      Create a Produced instance with provided keySerde and valueSerde.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      keySerde - Serde to use for serializing the key
      valueSerde - Serde to use for serializing the value
      Returns:
      A new Produced instance configured with keySerde and valueSerde
      See Also:
    • with

      public static <K, V> Produced<K,V> with(Serde<K> keySerde, Serde<V> valueSerde, StreamPartitioner<? super K,? super V> partitioner)
      Create a Produced instance with provided keySerde, valueSerde, and partitioner.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      keySerde - Serde to use for serializing the key
      valueSerde - Serde to use for serializing the value
      partitioner - the function used to determine how records are distributed among partitions of the topic, if not specified and keySerde provides a WindowedSerializer for the key WindowedStreamPartitioner will be used—otherwise DefaultStreamPartitioner will be used
      Returns:
      A new Produced instance configured with keySerde, valueSerde, and partitioner
      See Also:
    • as

      public static <K, V> Produced<K,V> as(String processorName)
      Create an instance of Produced with provided processor name.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      processorName - the processor name to be used. If null a default processor name will be generated
      Returns:
      a new instance of Produced
    • keySerde

      public static <K, V> Produced<K,V> keySerde(Serde<K> keySerde)
      Create a Produced instance with provided keySerde.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      keySerde - Serde to use for serializing the key
      Returns:
      A new Produced instance configured with keySerde
      See Also:
    • valueSerde

      public static <K, V> Produced<K,V> valueSerde(Serde<V> valueSerde)
      Create a Produced instance with provided valueSerde.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      valueSerde - Serde to use for serializing the key
      Returns:
      A new Produced instance configured with valueSerde
      See Also:
    • streamPartitioner

      public static <K, V> Produced<K,V> streamPartitioner(StreamPartitioner<? super K,? super V> partitioner)
      Create a Produced instance with provided partitioner.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      partitioner - the function used to determine how records are distributed among partitions of the topic, if not specified and the key serde provides a WindowedSerializer for the key WindowedStreamPartitioner will be used—otherwise DefaultStreamPartitioner will be used
      Returns:
      A new Produced instance configured with partitioner
      See Also:
    • withStreamPartitioner

      public Produced<K,V> withStreamPartitioner(StreamPartitioner<? super K,? super V> partitioner)
      Produce records using the provided partitioner.
      Parameters:
      partitioner - the function used to determine how records are distributed among partitions of the topic, if not specified and the key serde provides a WindowedSerializer for the key WindowedStreamPartitioner will be used—otherwise DefaultStreamPartitioner will be used
      Returns:
      this
    • withValueSerde

      public Produced<K,V> withValueSerde(Serde<V> valueSerde)
      Produce records using the provided valueSerde.
      Parameters:
      valueSerde - Serde to use for serializing the value
      Returns:
      this
    • withKeySerde

      public Produced<K,V> withKeySerde(Serde<K> keySerde)
      Produce records using the provided keySerde.
      Parameters:
      keySerde - Serde to use for serializing the key
      Returns:
      this
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public Produced<K,V> withName(String name)