Class JsonMergeUtils

  • All Implemented Interfaces:
    Serializable

    public class JsonMergeUtils
    extends Object
    implements Serializable
    A utility for merging arbitrary JSON trees. Used during default state generation to combine explicit and implicit default values where necessary.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonMergeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fasterxml.jackson.databind.JsonNode merge​(com.fasterxml.jackson.databind.JsonNode x, com.fasterxml.jackson.databind.JsonNode y)
      Returns x "merged into" y If x is null (java null, not JSON null!), return y If y is (java null, not JSON null!), return x If both x and y are primitive (including JSON null!), return x (i.e.
    • Constructor Detail

      • JsonMergeUtils

        public JsonMergeUtils()
    • Method Detail

      • merge

        public static com.fasterxml.jackson.databind.JsonNode merge​(com.fasterxml.jackson.databind.JsonNode x,
                                                                    com.fasterxml.jackson.databind.JsonNode y)
        Returns x "merged into" y If x is null (java null, not JSON null!), return y If y is (java null, not JSON null!), return x If both x and y are primitive (including JSON null!), return x (i.e. values in x take precedence over those in y) If x and y are of different types, return x If x and y are both objects, merge each field of x and y If an array field is set in both x and y, merge will be run on each element in turn. the length of the returned array will be max( length(x), length(y) ) See src/test/resources/JsonMergeUtilsTest.json for examples.
        Parameters:
        x - Json object
        y - Json object
        Returns:
        merged Json object