|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.jpa.client.local.backend.Comparisons
public class Comparisons
Non-instantiable utility methods for comparing two or more values.
Constructor Summary | |
---|---|
Comparisons()
|
Method Summary | |
---|---|
static String |
escapeRegexChar(char ch)
|
static boolean |
in(Object thingToCompare,
Object[] collection)
Tests if the first argument is equal to any of the remaining arguments. |
static Boolean |
like(String value,
String pattern,
String escapeChar)
Checks of the given value matches the given JPQL wildcard pattern. |
static int |
nullSafeCompare(Comparable c1,
Comparable c2)
Compares one potentially null Comparable to another. |
static boolean |
nullSafeEquals(Object o1,
Object o2)
Tests two potentially null object references for equality using approximate JPQL/SQL null semantics. |
static boolean |
nullSafeGreaterThan(Object o1,
Object o2)
Tests if one potentially null object reference is greater than another. |
static boolean |
nullSafeGreaterThanOrEqualTo(Object o1,
Object o2)
Tests if one potentially null object reference is greater than another. |
static boolean |
nullSafeLessThan(Object o1,
Object o2)
Tests if one potentially null object reference is greater than another. |
static boolean |
nullSafeLessThanOrEqualTo(Object o1,
Object o2)
Tests if one potentially null object reference is greater than another. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Comparisons()
Method Detail |
---|
public static boolean nullSafeEquals(Object o1, Object o2)
Specifically, this method returns true if and only if both arguments are non-null and either of the following conditions are met:
o1 == o2
o1.equals(o2)
o1
- One object to compare. Null is permitted.o2
- The other object to compare. Null is permitted.
public static boolean nullSafeGreaterThan(Object o1, Object o2)
o1
- One object to compare. Null is permitted.o2
- The other object to compare. Null is permitted.
o1 > o2
(either by primitive comparison or by
Comparable.compareTo()); false otherwisepublic static boolean nullSafeGreaterThanOrEqualTo(Object o1, Object o2)
o1
- One object to compare. Null is permitted.o2
- The other object to compare. Null is permitted.
o1 > o2
(either by primitive comparison or by
Comparable.compareTo()); false otherwisepublic static boolean nullSafeLessThan(Object o1, Object o2)
o1
- One object to compare. Null is permitted.o2
- The other object to compare. Null is permitted.
o1 > o2
(either by primitive comparison or by
Comparable.compareTo()); false otherwisepublic static boolean nullSafeLessThanOrEqualTo(Object o1, Object o2)
o1
- One object to compare. Null is permitted.o2
- The other object to compare. Null is permitted.
o1 > o2
(either by primitive comparison or by
Comparable.compareTo()); false otherwisepublic static int nullSafeCompare(Comparable c1, Comparable c2)
c1
- One object to compare. Null is permitted.c2
- The other object to compare. Null is permitted.
public static boolean in(Object thingToCompare, Object[] collection)
nullSafeEquals(Object, Object)
.
Special Case
If the collection has only one item in it, and that item is assignable to
Collection, then that collection will be searched rather than being treated
as a single scalar value. This allows correct behaviour for a JPQL query
SELECT x FROM MyClass x WHERE x.prop IN :param
and param
resolves to a collection value at runtime.
thingToCompare
- The item to compare against the remaining arguments.collection
- One or more items to test for equality with thingToCompare
.
collection
that compares equal
with thingToCompare
. False otherwise.public static Boolean like(String value, String pattern, String escapeChar)
value
- The string value to test. May be null.pattern
- The JPQL pattern to test against. Special characters are "_
", which matches any single character, and "%
", which
matches 0 or more characters.public static String escapeRegexChar(char ch)
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |