Class DelegatingByTopicDeserializer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.kafka.common.serialization.Deserializer<java.lang.Object>

    public class DelegatingByTopicDeserializer
    extends DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Deserializer<?>>
    implements org.apache.kafka.common.serialization.Deserializer<java.lang.Object>
    A Deserializer that delegates to other deserializers based on the topic name.
    Since:
    2.8
    • Constructor Detail

      • DelegatingByTopicDeserializer

        public DelegatingByTopicDeserializer()
        Construct an instance that will be configured in configure(Map, boolean) with consumer properties.
      • DelegatingByTopicDeserializer

        public DelegatingByTopicDeserializer​(java.util.Map<java.util.regex.Pattern,​org.apache.kafka.common.serialization.Deserializer<?>> delegates,
                                             org.apache.kafka.common.serialization.Deserializer<?> defaultDelegate)
        Construct an instance with the supplied mapping of topic name patterns to delegate deserializers.
        Parameters:
        delegates - the map of delegates.
        defaultDelegate - the default to use when no topic name match.
    • Method Detail

      • configure

        public void configure​(java.util.Map<java.lang.String,​?> configs,
                              boolean isKey)
        Specified by:
        configure in interface org.apache.kafka.common.serialization.Deserializer<java.lang.Object>
        Overrides:
        configure in class DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Deserializer<?>>
      • configureDelegate

        protected org.apache.kafka.common.serialization.Deserializer<?> configureDelegate​(java.util.Map<java.lang.String,​?> configs,
                                                                                          boolean isKey,
                                                                                          org.apache.kafka.common.serialization.Deserializer<?> delegate)
        Description copied from class: DelegatingByTopicSerialization
        Configure the delegate.
        Specified by:
        configureDelegate in class DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Deserializer<?>>
        Parameters:
        configs - the configs.
        isKey - true if this is for keys.
        delegate - the delegate.
        Returns:
        the delegate.
      • isInstance

        protected boolean isInstance​(java.lang.Object delegate)
        Description copied from class: DelegatingByTopicSerialization
        Return true if this object is an instance of T.
        Specified by:
        isInstance in class DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Deserializer<?>>
        Parameters:
        delegate - the delegate.
        Returns:
        true if a T.
      • deserialize

        public java.lang.Object deserialize​(java.lang.String topic,
                                            byte[] data)
        Specified by:
        deserialize in interface org.apache.kafka.common.serialization.Deserializer<java.lang.Object>
      • deserialize

        public java.lang.Object deserialize​(java.lang.String topic,
                                            org.apache.kafka.common.header.Headers headers,
                                            byte[] data)
        Specified by:
        deserialize in interface org.apache.kafka.common.serialization.Deserializer<java.lang.Object>