Interface MergeConfig<T>

  • All Known Implementing Classes:
    FacetsConfig, HttpConfig, JavaRuntimeCircuitBreakerConfig, KafkaConfig, KinesisConfig, OpenLineageConfig, SimpleMemoryCircuitBreakerConfig

    public interface MergeConfig<T>
    Contains methods to merge different config classes. It is mainly used to merge config entries from YAML files with config entries provided in another way (like integration specific configuration mechanism: SparkConf, FlinkConf).

    The general behaviour for classes implementing it is: implement a method that allows creating new config class which merges each property. When merging a non-value is taken and if two values are present then the argument of a method has higher precedence. If a property implements MergeConfig interface, then interface method is called. Merging logic needs to be aware of default values so that it does not overwrite a value with default entry.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.Map mergePropertyWith​(java.util.Map base, java.util.Map overwrite)
      Creates union of maps.
      default <T> T mergePropertyWith​(T base, T overwrite)
      Checks for nulls to avoid NPE.
      default T mergeWith​(T t)
      Merges current instance with instance provided.
      default <T> T mergeWithDefaultValue​(T base, T overwrite, T def)
      Overwrites base value with overwrite value only when it is does not equal default
      T mergeWithNonNull​(T t)
      Method to create new config class based on current instance and non-null argument value.
    • Method Detail

      • mergeWith

        default T mergeWith​(T t)
        Merges current instance with instance provided. Checks if argument provided is non-null.
        Parameters:
        t - object to be merged with
        Returns:
        merged value
      • mergePropertyWith

        default java.util.Map mergePropertyWith​(java.util.Map base,
                                                java.util.Map overwrite)
        Creates union of maps. In case of key collision, second parameter overwrites the first. Does null checking to avoid NPE
        Parameters:
        base - base value
        overwrite - overwrite value
        Returns:
        merged map
      • mergePropertyWith

        default <T> T mergePropertyWith​(T base,
                                        T overwrite)
        Checks for nulls to avoid NPE. If arguments are of different classes, the latter is returned. If they implement MergeConfig interface, then interface methods are used to merge values.
        Type Parameters:
        T - generic type of merged object
        Parameters:
        base - base value
        overwrite - overwrite value
        Returns:
        merged config entry
      • mergeWithDefaultValue

        default <T> T mergeWithDefaultValue​(T base,
                                            T overwrite,
                                            T def)
        Overwrites base value with overwrite value only when it is does not equal default
        Type Parameters:
        T - generic type of merged object
        Parameters:
        base - base value
        overwrite - overwrite value
        def - default value
        Returns:
        merged object
      • mergeWithNonNull

        T mergeWithNonNull​(T t)
        Method to create new config class based on current instance and non-null argument value. In most cases, implementation needs to create a new instance of T, while merging all the properties.
        Parameters:
        t - overwrite value
        Returns:
        merged config entry