Class GenericJsonConfigurationMerger<T>

  • All Implemented Interfaces:
    ConfigurationMerger<T>
    Direct Known Subclasses:
    JSONObjectConfigurationMerger

    public class GenericJsonConfigurationMerger<T>
    extends AbstractConfigurationMerger<T>
    A generic ConfigurationMerger that combines two Configuration objects of type JSON.

    The operation is provider-agnostic and depends on a specialized JsonProvider which must be specified via constructor.

    The resulting JSON document from the merge operation shall contain all exclusive objects from source documents and in case of In case of key collisions (i.e., the same key appears in both documents), the following rules will be applied:

    • for simple values, such as strings, numbers and boolean values, the value from the highest-precedence Configuration will be selected;
    • if the value is a JSON object in both JSON sources, the two objects will be merged recursively; if the types are not compatible (e.g.: JSON object in one side and simple value or array in the other), then a copy of the object from the highest-precedence Configuration will be selected as fallback;
    • if the value is a JSON array in both JSON sources, then all elements from both two arrays will be copied distinctively (i.e., repeated elements will not be copied to the resulting JSON document); if the types are not compatible (e.g.: JSON array in one side and simple value or complex object in the other), then a copy of the object from the highest-precedence Configuration will be selected as fallback

    Note: For advanced merge options, refer to JsonMergeOption.

    Since:
    2.1.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    See Also:
    ConfigurationMerger, JsonProvider, JsonMergeOption
    • Constructor Detail

      • GenericJsonConfigurationMerger

        public GenericJsonConfigurationMerger​(net.obvj.jsonmerge.provider.JsonProvider<T> jsonProvider)
        Creates a new JSON Configuration Merger for a specific provider.
        Parameters:
        jsonProvider - the JsonProvider to use; not null
        Throws:
        NullPointerException - if the specified JsonProvider is null