Class ObjectComparator

java.lang.Object
org.pipservices3.commons.validate.ObjectComparator

public class ObjectComparator extends Object
Helper class to perform comparison operations over arbitrary values.

### Example ###

 
 ObjectComparator.compare(2, "GT", 1);        // Result: true
 ObjectComparator.areEqual("A", "B");         // Result: false
 
 
  • Constructor Details

    • ObjectComparator

      public ObjectComparator()
  • Method Details

    • compare

      public static boolean compare(Object value1, String operation, Object value2)
      Perform comparison operation over two arguments. The operation can be performed over values of any type.
      Parameters:
      value1 - the first argument to compare
      operation - the comparison operation
      value2 - the second argument to compare
      Returns:
      result of the comparison operation
    • areEqual

      public static boolean areEqual(Object value1, Object value2)
      Checks if two values are equal. The operation can be performed over values of any type.
      Parameters:
      value1 - the first value to compare
      value2 - the second value to compare
      Returns:
      true if values are equal and false otherwise
    • areNotEqual

      public static boolean areNotEqual(Object value1, Object value2)
      Checks if two values are NOT equal The operation can be performed over values of any type.
      Parameters:
      value1 - the first value to compare
      value2 - the second value to compare
      Returns:
      true if values are NOT equal and false otherwise
    • less

      public static boolean less(Object value1, Object value2)
      Checks if first value is less than the second one. The operation can be performed over numbers or strings.
      Parameters:
      value1 - the first value to compare
      value2 - the second value to compare
      Returns:
      true if the first value is less than second and false otherwise.
    • more

      public static boolean more(Object value1, Object value2)
      Checks if first value is greater than the second one. The operation can be performed over numbers or strings.
      Parameters:
      value1 - the first value to compare
      value2 - the second value to compare
      Returns:
      true if the first value is greater than second and false otherwise.
    • match

      public static boolean match(Object value1, Object value2)
      Checks if string matches a regular expression
      Parameters:
      value1 - a string value to match
      value2 - a regular expression string
      Returns:
      true if the value matches regular expression and false otherwise.