Package net.obvj.confectory.merger
Class GenericJsonConfigurationMerger<T>
- java.lang.Object
-
- net.obvj.confectory.merger.AbstractConfigurationMerger<T>
-
- net.obvj.confectory.merger.GenericJsonConfigurationMerger<T>
-
- All Implemented Interfaces:
ConfigurationMerger<T>
- Direct Known Subclasses:
JSONObjectConfigurationMerger
public class GenericJsonConfigurationMerger<T> extends AbstractConfigurationMerger<T>
A genericConfigurationMergerthat combines twoConfigurationobjects of type JSON.The operation is provider-agnostic and depends on a specialized
JsonProviderwhich 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
Configurationwill 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
Configurationwill 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
Configurationwill 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 Summary
Constructors Constructor Description GenericJsonConfigurationMerger(net.obvj.jsonmerge.provider.JsonProvider<T> jsonProvider)Creates a new JSON Configuration Merger for a specific provider.
-
-
-
Constructor Detail
-
GenericJsonConfigurationMerger
public GenericJsonConfigurationMerger(net.obvj.jsonmerge.provider.JsonProvider<T> jsonProvider)
Creates a new JSON Configuration Merger for a specific provider.- Parameters:
jsonProvider- theJsonProviderto use; notnull- Throws:
NullPointerException- if the specified JsonProvider is null
-
-