Class SchemaDiff

java.lang.Object
com.axelor.studio.mapper.diff.SchemaDiff

public class SchemaDiff extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    SchemaDiff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target)
    Create a new SchemaDiff with the given source and target JSON nodes using the default similarity threshold.
    SchemaDiff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target, double threshold)
    Create a new SchemaDiff with the given source and target JSON nodes and custom similarity threshold.
  • Method Summary

    Modifier and Type
    Method
    Description
    Compute the differences between the source and target nodes.
    Get the changes between the source and target nodes.
    Normalize the changes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SchemaDiff

      public SchemaDiff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target)
      Create a new SchemaDiff with the given source and target JSON nodes using the default similarity threshold.
      Parameters:
      source - the source JSON node
      target - the target JSON node
    • SchemaDiff

      public SchemaDiff(com.fasterxml.jackson.databind.JsonNode source, com.fasterxml.jackson.databind.JsonNode target, double threshold)
      Create a new SchemaDiff with the given source and target JSON nodes and custom similarity threshold.
      Parameters:
      source - the source JSON node
      target - the target JSON node
      threshold - the threshold value between 0 and 1 to determine node similarity
  • Method Details

    • getChanges

      public List<SchemaChange> getChanges()
      Get the changes between the source and target nodes.
      Returns:
      the changes
    • compute

      public SchemaDiff compute()
      Compute the differences between the source and target nodes.

      This method is used to compute the differences between two nodes and create the necessary changes.

      It will replace the existing changes with the new ones.

      Returns:
      the same SchemaDiff instance
    • normalize

      public SchemaDiff normalize()
      Normalize the changes.

      This method is used to normalize the changes by normalizing the insert, remove on same nodes to move and re-order the changes based on the preference.

      • Remove and Insert on same node are converted to Move
      • Changes are re-ordered based in the preference of Update, Insert, Move, Remove

      It will replace the existing changes with the normalized ones.

      Returns:
      the same SchemaDiff instance