Class JacksonVersionBridge

java.lang.Object
com.flipkart.zjsonpatch.mapping.JacksonVersionBridge

public final class JacksonVersionBridge extends Object
Bridge for wrapping and unwrapping Jackson JsonNodes across different versions.

This class handles the bridging responsibility - converting between native Jackson nodes and wrapped nodes. It automatically detects the Jackson version of nodes by checking if they are instances of known Jackson JsonNode types, properly handling inheritance and subclassed nodes.

Since:
0.6.0
Author:
Mariusz Sondecki
  • Method Details

    • wrap

      public static JsonNodeWrapper wrap(Object nativeNode)
      Wraps a native Jackson JsonNode in the appropriate JsonNodeWrapper.

      Parameters:
      nativeNode - the Jackson JsonNode to wrap
      Returns:
      wrapped JsonNode, or null if input is null
      Throws:
      IllegalArgumentException - if the node type is unsupported for the selected Jackson version
      JacksonVersionException - if wrapper classes cannot be loaded or instantiated
    • unwrap

      public static <T> T unwrap(JsonNodeWrapper wrapper)
      Unwraps a JsonNodeWrapper to its underlying Jackson JsonNode.
      Parameters:
      wrapper - the wrapper to unwrap
      Returns:
      the underlying Jackson JsonNode, or null if wrapper is null