- java.lang.Object
-
- org.apache.logging.log4j.util.Assert
-
public final class Assert extends Object
Utility class providing common validation logic.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isEmpty(Object o)
Checks if an object has empty semantics.static boolean
isNonEmpty(Object o)
Opposite ofisEmpty(Object)
.static <T> T
requireNonEmpty(T value)
Checks a value for emptiness and throws an IllegalArgumentException if it's empty.static <T> T
requireNonEmpty(T value, String message)
Checks a value for emptiness and throws an IllegalArgumentException if it's empty.static int
valueIsAtLeast(int value, int minValue)
-
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(Object o)
Checks if an object has empty semantics. The following scenarios are considered empty:null
- empty
CharSequence
- empty array
- empty
Iterable
- empty
Map
- Parameters:
o
- value to check for emptiness- Returns:
- true if the value is empty, false otherwise
- Since:
- 2.8
-
isNonEmpty
public static boolean isNonEmpty(Object o)
Opposite ofisEmpty(Object)
.- Parameters:
o
- value to check for non-emptiness- Returns:
- true if the value is non-empty, false otherwise
- Since:
- 2.8
-
requireNonEmpty
public static <T> T requireNonEmpty(T value)
Checks a value for emptiness and throws an IllegalArgumentException if it's empty.- Type Parameters:
T
- type of value- Parameters:
value
- value to check for emptiness- Returns:
- the provided value if non-empty
- Since:
- 2.8
-
requireNonEmpty
public static <T> T requireNonEmpty(T value, String message)
Checks a value for emptiness and throws an IllegalArgumentException if it's empty.- Type Parameters:
T
- type of value- Parameters:
value
- value to check for emptinessmessage
- message to provide in exception- Returns:
- the provided value if non-empty
- Since:
- 2.8
-
valueIsAtLeast
public static int valueIsAtLeast(int value, int minValue)
-
-