Class DelegatingByTopicSerialization<T extends java.io.Closeable>

  • Type Parameters:
    T - the type.
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    DelegatingByTopicDeserializer, DelegatingByTopicSerializer

    public abstract class DelegatingByTopicSerialization<T extends java.io.Closeable>
    extends java.lang.Object
    implements java.io.Closeable
    Base class with common code for delegating by topic serialization.
    Since:
    2.8
    Author:
    Gary Russell
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CASE_SENSITIVE
      Set to false to make topic pattern matching case-insensitive.
      static java.lang.String KEY_SERIALIZATION_TOPIC_CONFIG
      Name of the configuration property containing the serialization topic pattern map for keys with format pattern:class,....
      static java.lang.String KEY_SERIALIZATION_TOPIC_DEFAULT
      Name of the default delegate for keys when no topic name match is fount.
      static java.lang.String VALUE_SERIALIZATION_TOPIC_CONFIG
      Name of the configuration property containing the serialization selector map for values with format selector:class,....
      static java.lang.String VALUE_SERIALIZATION_TOPIC_DEFAULT
      Name of the default delegate for keys when no topic name match is fount.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addDelegate​(java.util.regex.Pattern pattern, T serializer)  
      protected void build​(java.util.Map<java.lang.String,​?> configs, boolean isKey, java.lang.String configKey, java.lang.Object delegate, java.util.regex.Pattern pattern)  
      protected void buildDefault​(java.util.Map<java.lang.String,​?> configs, java.lang.String configKey, boolean isKey, java.lang.Object delegate)  
      void close()  
      protected void configure​(java.util.Map<java.lang.String,​?> configs, boolean isKey)  
      protected abstract T configureDelegate​(java.util.Map<java.lang.String,​?> configs, boolean isKey, T delegate)
      Configure the delegate.
      protected T findDelegate​(java.lang.String topic)
      Determine the delegate for the topic.
      protected T instantiateAndConfigure​(java.util.Map<java.lang.String,​?> configs, boolean isKey, java.util.Map<java.util.regex.Pattern,​T> delegates2, java.util.regex.Pattern pattern, java.lang.Class<?> clazz)  
      protected abstract boolean isInstance​(java.lang.Object delegate)
      Return true if this object is an instance of T.
      T removeDelegate​(java.util.regex.Pattern pattern)  
      void setCaseSensitive​(boolean caseSensitive)
      Set to false to make topic name matching case insensitive.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • VALUE_SERIALIZATION_TOPIC_CONFIG

        public static final java.lang.String VALUE_SERIALIZATION_TOPIC_CONFIG
        Name of the configuration property containing the serialization selector map for values with format selector:class,....
        See Also:
        Constant Field Values
      • KEY_SERIALIZATION_TOPIC_CONFIG

        public static final java.lang.String KEY_SERIALIZATION_TOPIC_CONFIG
        Name of the configuration property containing the serialization topic pattern map for keys with format pattern:class,....
        See Also:
        Constant Field Values
      • VALUE_SERIALIZATION_TOPIC_DEFAULT

        public static final java.lang.String VALUE_SERIALIZATION_TOPIC_DEFAULT
        Name of the default delegate for keys when no topic name match is fount.
        See Also:
        Constant Field Values
      • KEY_SERIALIZATION_TOPIC_DEFAULT

        public static final java.lang.String KEY_SERIALIZATION_TOPIC_DEFAULT
        Name of the default delegate for keys when no topic name match is fount.
        See Also:
        Constant Field Values
      • CASE_SENSITIVE

        public static final java.lang.String CASE_SENSITIVE
        Set to false to make topic pattern matching case-insensitive.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DelegatingByTopicSerialization

        public DelegatingByTopicSerialization()
      • DelegatingByTopicSerialization

        public DelegatingByTopicSerialization​(java.util.Map<java.util.regex.Pattern,​T> delegates,
                                              T defaultDelegate)
    • Method Detail

      • setCaseSensitive

        public void setCaseSensitive​(boolean caseSensitive)
        Set to false to make topic name matching case insensitive.
        Parameters:
        caseSensitive - false for case insensitive.
      • configure

        protected void configure​(java.util.Map<java.lang.String,​?> configs,
                                 boolean isKey)
      • build

        protected void build​(java.util.Map<java.lang.String,​?> configs,
                             boolean isKey,
                             java.lang.String configKey,
                             java.lang.Object delegate,
                             java.util.regex.Pattern pattern)
      • buildDefault

        protected void buildDefault​(java.util.Map<java.lang.String,​?> configs,
                                    java.lang.String configKey,
                                    boolean isKey,
                                    java.lang.Object delegate)
      • configureDelegate

        protected abstract T configureDelegate​(java.util.Map<java.lang.String,​?> configs,
                                               boolean isKey,
                                               T delegate)
        Configure the delegate.
        Parameters:
        configs - the configs.
        isKey - true if this is for keys.
        delegate - the delegate.
        Returns:
        the delegate.
      • isInstance

        protected abstract boolean isInstance​(java.lang.Object delegate)
        Return true if this object is an instance of T.
        Parameters:
        delegate - the delegate.
        Returns:
        true if a T.
      • instantiateAndConfigure

        protected T instantiateAndConfigure​(java.util.Map<java.lang.String,​?> configs,
                                            boolean isKey,
                                            java.util.Map<java.util.regex.Pattern,​T> delegates2,
                                            @Nullable
                                            java.util.regex.Pattern pattern,
                                            java.lang.Class<?> clazz)
      • addDelegate

        public void addDelegate​(java.util.regex.Pattern pattern,
                                T serializer)
      • removeDelegate

        @Nullable
        public T removeDelegate​(java.util.regex.Pattern pattern)
      • findDelegate

        protected T findDelegate​(java.lang.String topic)
        Determine the delegate for the topic.
        Parameters:
        topic - the topic.
        Returns:
        the delegate.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable