Class CompareService

java.lang.Object
com.eurodyn.qlack.fuse.acv.service.CompareService

@Service public class CompareService extends Object
Provides functionality to compare two objects of the same class.
Author:
European Dynamics SA
  • Constructor Details

    • CompareService

      @Autowired public CompareService(org.javers.core.Javers javers, VersioningService versioningService)
  • Method Details

    • hasChanges

      public <T> boolean hasChanges(@NonNull T obj1, @NonNull T obj2)
      Compares two objects and returns if they have changes or not.
      Type Parameters:
      T - the type of the objects to compare, so to ensure that the objects are of the same class
      Parameters:
      obj1 - the first object to compare
      obj2 - the second object to compare
      Returns:
      true if the objects they have changes, else false
    • compare

      public <T> List<ChangeDTO> compare(@NonNull T obj1, @NonNull T obj2)
      Compares two objects and returns the changes.
      Type Parameters:
      T - the type of the objects to compare, so to ensure that the objects are of the same class
      Parameters:
      obj1 - the first object to compare
      obj2 - the second object to compare
      Returns:
      a list with the changes between the two comparing objects
    • compareVersions

      public List<ChangeDTO> compareVersions(Object object, long version1, long version2)
      Compares two object versions and returns the changes.

      Throws a QDoesNotExistException when one of the requested versions doesn't exist.
      Parameters:
      object - the object to find the requested versions.
      version1 - number of the first version to compare with
      version2 - number of the second version to compare with
      Returns:
      a list with the changes between the two comparing objects
    • compareObjectWithVersion

      public List<ChangeDTO> compareObjectWithVersion(Object object, long version)
      Compares an object with a specific version and returns the changes.

      Throws a QDoesNotExistException when the requested version doesn't exist.
      Parameters:
      object - the object to compare with the latest version.
      version - number of the version to compare with
      Returns:
      a list with the changes between the two comparing objects
    • compareObjectWithLatestVersion

      public List<ChangeDTO> compareObjectWithLatestVersion(Object object)
      Compares an object with the latest version and returns the changes.

      Throws a QDoesNotExistException when no committed version exists.
      Parameters:
      object - the object to compare with the latest version.
      Returns:
      a list with the changes between the two comparing objects
    • convertToChangeDTO

      protected ChangeDTO convertToChangeDTO(org.javers.core.diff.changetype.ValueChange change)