com.hazelcast.util
public final class Preconditions extends Object
Modifier and Type | Method and Description |
---|---|
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 <E> E |
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 <E> E |
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 <T> T |
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 <E> E |
isNotNull(E argument,
String argName)
Tests if a string is not null.
|
public static <T> T checkNotNull(T argument, String errorMessage)
argument
- the argument tested to see if it is not null.errorMessage
- the errorMessageNullPointerException
- if argument is nullpublic static String checkHasText(String argument, String errorMessage)
argument
- the string tested to see if it contains text.errorMessage
- the errorMessageIllegalArgumentException
- if the string is emptypublic 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 errorMessageIllegalArgumentException
- 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 errorMessageIllegalArgumentException
- 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 messageIllegalArgumentException
- 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 messageIllegalArgumentException
- 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 messageIllegalArgumentException
- 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 backupsIllegalArgumentException
- 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 backupsIllegalArgumentException
- 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 errorMessageIllegalArgumentException
- 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 errorMessageIllegalArgumentException
- 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 errorMessageIllegalArgumentException
- 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 errorMessageIllegalArgumentException
- if the supplied expression is false
.Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.