Class Assert
java.lang.Object
org.apache.logging.log4j.core.util.Assert
Utility class providing common validation logic.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
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 Details
-
isEmpty
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
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
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)
-