Class Assert
java.lang.Object
org.apache.logging.log4j.core.util.Assert
Utility class providing common validation logic.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if an object has empty semantics.static booleanisNonEmpty(Object o) Opposite ofisEmpty(Object).static <T> TrequireNonEmpty(T value) Checks a value for emptiness and throws an IllegalArgumentException if it's empty.static <T> TrequireNonEmpty(T value, String message) Checks a value for emptiness and throws an IllegalArgumentException if it's empty.static intvalueIsAtLeast(int value, int minValue)
-
Constructor Details
-
Assert
private Assert()
-
-
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)
-