Package com.ongres.scram.common.util
Class Preconditions
java.lang.Object
com.ongres.scram.common.util.Preconditions
Simple methods similar to Precondition class. Avoid importing full library.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkArgument
(boolean check, String valueName) Checks that the argument is valid, based in a check boolean condition.static String
checkNotEmpty
(String value, String valueName) Checks that the String is not null and not emptystatic <T> T
checkNotNull
(T value, String valueName) Checks that the argument is not null.static int
Checks that the integer argument is positive.
-
Constructor Details
-
Preconditions
public Preconditions()
-
-
Method Details
-
checkNotNull
Checks that the argument is not null.- Type Parameters:
T
- The type of the value- Parameters:
value
- The value to be checkedvalueName
- The name of the value that is checked in the method- Returns:
- The same value passed as argument
- Throws:
IllegalArgumentException
- If value is null
-
checkNotEmpty
Checks that the String is not null and not empty- Parameters:
value
- The String to checkvalueName
- The name of the value that is checked in the method- Returns:
- The same String passed as argument
- Throws:
IllegalArgumentException
- If value is null or empty
-
checkArgument
Checks that the argument is valid, based in a check boolean condition.- Parameters:
check
- The boolean checkvalueName
- The name of the value that is checked in the method- Throws:
IllegalArgumentException
-
gt0
Checks that the integer argument is positive.- Parameters:
value
- The value to be checkedvalueName
- The name of the value that is checked in the method- Returns:
- The same value passed as argument
- Throws:
IllegalArgumentException
- If value is null
-