Package com.oracle.bmc.util.internal
Enum Validate
- java.lang.Object
-
- java.lang.Enum<Validate>
-
- com.oracle.bmc.util.internal.Validate
-
- All Implemented Interfaces:
Serializable
,Comparable<Validate>
public enum Validate extends Enum<Validate>
Argument validation.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
inclusiveBetween(long minimum, long maximum, long value, String reason, Object... values)
ThrowIllegalArgumentException
if value is strictly less than minimum or strictly greater than maximum.static <T> T
isInstanceOf(Class<?> clazz, T o, String reason, Object... values)
ThrowIllegalArgumentException
if the object is not an instance of the class.static void
isTrue(boolean condition, String reason, Object... values)
ThrowIllegalArgumentException
if the condition is false.static <T> T[]
noNullElements(T[] array, String reason, Object... values)
ThrowIllegalArgumentException
if one of the array elements is null.static String
notBlank(String s, String reason, Object... values)
Throw @NullPointerException
if the string is null, orIllegalArgumentException
if the string is just whitespace.static <T> T[]
notEmpty(T[] array, String reason, Object... values)
ThrowIllegalArgumentException
if the array is emptystatic <T> T
notNull(T o, String reason, Object... values)
ThrowNullPointerException
if the object is null.static Validate
valueOf(String name)
Returns the enum constant of this type with the specified name.static Validate[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static Validate[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Validate c : Validate.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Validate valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
notNull
public static <T> T notNull(T o, String reason, Object... values)
ThrowNullPointerException
if the object is null.- Parameters:
o
- object that has to be non-nullreason
- exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the object
- Throws:
NullPointerException
- if the object is null
-
isInstanceOf
public static <T> T isInstanceOf(Class<?> clazz, T o, String reason, Object... values)
ThrowIllegalArgumentException
if the object is not an instance of the class.- Parameters:
clazz
- the class the object has to beo
- the objectreason
- the exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the object
- Throws:
IllegalArgumentException
- if the object is not an instance of the class
-
notBlank
public static String notBlank(String s, String reason, Object... values)
Throw @NullPointerException
if the string is null, orIllegalArgumentException
if the string is just whitespace.- Parameters:
s
- stringreason
- exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the string
- Throws:
NullPointerException
- if the object is nullIllegalArgumentException
- if the object is just whitespace.
-
isTrue
public static void isTrue(boolean condition, String reason, Object... values)
ThrowIllegalArgumentException
if the condition is false.- Parameters:
condition
- the conditionreason
- exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Throws:
NullPointerException
- if the condition is false
-
inclusiveBetween
public static long inclusiveBetween(long minimum, long maximum, long value, String reason, Object... values)
ThrowIllegalArgumentException
if value is strictly less than minimum or strictly greater than maximum.- Parameters:
minimum
- the minimum, inclusivemaximum
- the maximum, inclusivevalue
- the value to checkreason
- the exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the value
- Throws:
IllegalArgumentException
- if the value is out of bounds
-
noNullElements
public static <T> T[] noNullElements(T[] array, String reason, Object... values)
ThrowIllegalArgumentException
if one of the array elements is null.- Type Parameters:
T
- array element type- Parameters:
array
- array to checkreason
- exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the array
- Throws:
IllegalArgumentException
- if one of the array elements is null
-
notEmpty
public static <T> T[] notEmpty(T[] array, String reason, Object... values)
ThrowIllegalArgumentException
if the array is empty- Type Parameters:
T
- array element type- Parameters:
array
- array to checkreason
- exception messagevalues
- values to be put in placeholders in reason (e.g. “%s”).- Returns:
- the array
- Throws:
IllegalArgumentException
- if the array is empty
-
-