|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hazelcast.util.Preconditions
public final class Preconditions
A utility class for validating arguments and state.
| Method Summary | ||
|---|---|---|
static int |
checkAsyncBackupCount(int currentBackupCount,
int newAsyncBackupCount)
Tests if the newAsyncBackupCount count is valid. |
|
static int |
checkBackupCount(int newBackupCount,
int currentAsyncBackupCount)
Tests if the newBackupCount count is valid. |
|
static void |
checkFalse(boolean expression,
String errorMessage)
Tests whether the supplied expression is false. |
|
static String |
checkHasText(String argument,
String errorMessage)
Tests if a string contains text. |
|
static
|
checkInstanceOf(Class type,
E object,
String errorMessage)
Tests whether the supplied object is an instance of the supplied class type. |
|
static long |
checkNegative(long value,
String errorMessage)
Tests if a long value is not negative. |
|
static
|
checkNotInstanceOf(Class type,
E object,
String errorMessage)
Tests the supplied object to see if it is not a type of the supplied class. |
|
static int |
checkNotNegative(int value,
String errorMessage)
Tests if a value is not negative. |
|
static long |
checkNotNegative(long value,
String errorMessage)
Tests if a value is not negative. |
|
static
|
checkNotNull(T argument,
String errorMessage)
Tests if an argument is not null. |
|
static int |
checkPositive(int value,
String errorMessage)
Tests if a value is positive; larger than 0. |
|
static long |
checkPositive(long value,
String errorMessage)
Tests if a value is positive; so larger than 0. |
|
static void |
checkTrue(boolean expression,
String errorMessage)
Tests whether the supplied expression is true. |
|
static
|
isNotNull(E argument,
String argName)
Tests if a string is not null. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> T checkNotNull(T argument,
String errorMessage)
argument - the argument tested to see if it is not null.errorMessage - the errorMessage
NullPointerException - if argument is null
public static String checkHasText(String argument,
String errorMessage)
argument - the string tested to see if it contains text.errorMessage - the errorMessage
IllegalArgumentException - if the string is empty
public static <E> E isNotNull(E argument,
String argName)
argument - the string tested to see if it is not null.argName - the string name (used in message if an error is thrown).
IllegalArgumentException - if the string is null.
public static long checkNotNegative(long value,
String errorMessage)
value - the value tested to see if it is not negative.errorMessage - the errorMessage
IllegalArgumentException - if the value is negative.
public static int checkNotNegative(int value,
String errorMessage)
value - the value tested to see if it is not negative.errorMessage - the errorMessage
IllegalArgumentException - if the value is negative.
public static long checkNegative(long value,
String errorMessage)
value - the long value tested to see if it is not negative.errorMessage - the message
IllegalArgumentException - if the value is negative.
public static long checkPositive(long value,
String errorMessage)
value - the value tested to see if it is positive.errorMessage - the message
IllegalArgumentException - if the value is not positive.
public static int checkPositive(int value,
String errorMessage)
value - the value tested to see if it is positive.errorMessage - the message
IllegalArgumentException - if the value is not positive.
public static int checkBackupCount(int newBackupCount,
int currentAsyncBackupCount)
newBackupCount - the number of sync backupscurrentAsyncBackupCount - the current number of async backups
IllegalArgumentException - if newBackupCount is smaller than 0, or larger than the maximum
number of backups.
public static int checkAsyncBackupCount(int currentBackupCount,
int newAsyncBackupCount)
currentBackupCount - the current number of backupsnewAsyncBackupCount - the new number of async backups
IllegalArgumentException - if asyncBackupCount is smaller than 0, or larger than the maximum
number of backups.
public static <E> E checkInstanceOf(Class type,
E object,
String errorMessage)
type - the expected type.object - the object tested against the expected type.errorMessage - the errorMessage
IllegalArgumentException - if the object is not an instance of the expected type.
public static <E> E checkNotInstanceOf(Class type,
E object,
String errorMessage)
type - the type that is not of the supplied class.object - the object tested against the type.errorMessage - the errorMessage
IllegalArgumentException - if the object is an instance of the type that is not of the expected class.
public static void checkFalse(boolean expression,
String errorMessage)
false.
expression - the expression tested to see if it is false.errorMessage - the errorMessage
IllegalArgumentException - if the supplied expression is true.
public static void checkTrue(boolean expression,
String errorMessage)
true.
expression - the expression tested to see if it is true.errorMessage - the errorMessage
IllegalArgumentException - if the supplied expression is false.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||