public final class Constraint extends Object
ConstraintViolationException
.Modifier | Constructor and Description |
---|---|
private |
Constraint()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static <T> Collection<T> |
isEmpty(Collection<T> collection,
String message)
Checks that the given collection is empty.
|
static boolean |
isFalse(boolean b,
String message)
Checks that the given boolean is false.
|
static long |
isGreaterThan(long threshold,
long number,
String message)
Checks that the given number is greater than a given threshold.
|
static long |
isGreaterThanOrEqual(long threshold,
long number,
String message)
Checks that the given number is greater than, or equal to, a given threshold.
|
static long |
isLessThan(long threshold,
long number,
String message)
Checks that the given number is less than a given threshold.
|
static long |
isLessThanOrEqual(long threshold,
long number,
String message)
Checks that the given number is less than, or equal to, a given threshold.
|
static byte[] |
isNotEmpty(byte[] array,
String message)
Checks that the given byte array is not empty.
|
static <T> Collection<T> |
isNotEmpty(Collection<T> collection,
String message)
Checks that the given collection is not empty.
|
static String |
isNotEmpty(String string,
String message)
Checks that the given string is not empty.
|
static <T> T[] |
isNotEmpty(T[] array,
String message)
Checks that the given array is not empty.
|
static <T> T |
isNotNull(T obj,
String message)
Checks that the given object is not null.
|
static <T> T |
isNull(T obj,
String message)
Checks that the given object is null.
|
static boolean |
isTrue(boolean b,
String message)
Checks that the given boolean is true.
|
static <T> T[] |
noNullItems(T[] array,
String message)
Checks that the array does not contain any null elements.
|
static long |
numberInRangeExclusive(long lowerTheshold,
long upperThreshold,
long number,
String message)
Checks that the given number is in the exclusive range.
|
static long |
numberInRangeInclusive(long lowerTheshold,
long upperThreshold,
long number,
String message)
Checks that the given number is in the inclusive range.
|
@Nonnull public static <T> Collection<T> isEmpty(@Nonnull Collection<T> collection, @Nonnull String message)
ConstraintViolationException
is thrown.T
- type of items in the collectioncollection
- collection to checkmessage
- message used in the ConstraintViolationException
public static boolean isFalse(boolean b, @Nonnull String message)
ConstraintViolationException
is thrown.b
- boolean to checkmessage
- message used in ConstraintViolationException
public static long isGreaterThan(long threshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.threshold
- the thresholdnumber
- the number to be checkedmessage
- message used in the ConstraintViolationException
public static long isGreaterThanOrEqual(long threshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.threshold
- the thresholdnumber
- the number to be checkedmessage
- message used in the ConstraintViolationException
public static long isLessThan(long threshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.threshold
- the thresholdnumber
- the number to be checkedmessage
- message used in the ConstraintViolationException
public static long isLessThanOrEqual(long threshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.threshold
- the thresholdnumber
- the number to be checkedmessage
- message used in the ConstraintViolationException
@Nonnull public static <T> Collection<T> isNotEmpty(@Nonnull Collection<T> collection, @Nonnull String message)
ConstraintViolationException
is thrown.T
- type of items in the collectioncollection
- collection to checkmessage
- message used in the ConstraintViolationException
@Nonnull public static <T> T[] isNotEmpty(@Nonnull T[] array, @Nonnull String message)
ConstraintViolationException
is thrown.T
- type of items in the arrayarray
- array to checkmessage
- message used in the ConstraintViolationException
@Nonnull public static byte[] isNotEmpty(@Nonnull byte[] array, @Nonnull String message)
ConstraintViolationException
is thrown.array
- array to checkmessage
- message used in the ConstraintViolationException
@Nonnull public static String isNotEmpty(@Nonnull String string, @Nonnull String message)
ConstraintViolationException
is thrown.string
- string to checkmessage
- message used in the ConstraintViolationException
@Nonnull public static <T> T isNotNull(@Nullable T obj, @Nonnull String message)
ConstraintViolationException
is
thrown.T
- object typeobj
- object to checkmessage
- message used in ConstraintViolationException
@Nullable public static <T> T isNull(@Nullable T obj, @Nonnull String message)
ConstraintViolationException
is
thrown.T
- object typeobj
- object to checkmessage
- message used in ConstraintViolationException
public static boolean isTrue(boolean b, @Nonnull String message)
ConstraintViolationException
is thrown.b
- boolean to checkmessage
- message used in ConstraintViolationException
@Nonnull public static <T> T[] noNullItems(@Nonnull T[] array, @Nonnull String message)
T
- type of elements in the arrayarray
- array to checkmessage
- message used in the ConstraintViolationException
public static long numberInRangeExclusive(long lowerTheshold, long upperThreshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.lowerTheshold
- lower bound of the rangeupperThreshold
- upper bound of the rangenumber
- number to checkmessage
- message used in the ConstraintViolationException
public static long numberInRangeInclusive(long lowerTheshold, long upperThreshold, long number, @Nonnull String message)
ConstraintViolationException
is thrown.lowerTheshold
- lower bound of the rangeupperThreshold
- upper bound of the rangenumber
- number to checkmessage
- message used in the ConstraintViolationException
Copyright © 1999–2019. All rights reserved.