Class ObjectComparator
java.lang.Object
org.pipservices3.commons.validate.ObjectComparator
Helper class to perform comparison operations over arbitrary values.
### Example ###
ObjectComparator.compare(2, "GT", 1); // Result: true
ObjectComparator.areEqual("A", "B"); // Result: false
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Checks if two values are equal.static boolean
areNotEqual
(Object value1, Object value2) Checks if two values are NOT equal The operation can be performed over values of any type.static boolean
Perform comparison operation over two arguments.static boolean
Checks if first value is less than the second one.static boolean
Checks if string matches a regular expressionstatic boolean
Checks if first value is greater than the second one.
-
Constructor Details
-
ObjectComparator
public ObjectComparator()
-
-
Method Details
-
compare
Perform comparison operation over two arguments. The operation can be performed over values of any type.- Parameters:
value1
- the first argument to compareoperation
- the comparison operationvalue2
- the second argument to compare- Returns:
- result of the comparison operation
-
areEqual
Checks if two values are equal. The operation can be performed over values of any type.- Parameters:
value1
- the first value to comparevalue2
- the second value to compare- Returns:
- true if values are equal and false otherwise
-
areNotEqual
Checks if two values are NOT equal The operation can be performed over values of any type.- Parameters:
value1
- the first value to comparevalue2
- the second value to compare- Returns:
- true if values are NOT equal and false otherwise
-
less
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 comparevalue2
- the second value to compare- Returns:
- true if the first value is less than second and false otherwise.
-
more
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 comparevalue2
- the second value to compare- Returns:
- true if the first value is greater than second and false otherwise.
-
match
Checks if string matches a regular expression- Parameters:
value1
- a string value to matchvalue2
- a regular expression string- Returns:
- true if the value matches regular expression and false otherwise.
-