Class ObjectUtil
- java.lang.Object
-
- gov.nist.secauto.decima.core.util.ObjectUtil
-
public class ObjectUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
requireNonEmpty(String str)
Checks that the provided string is not empty.static String
requireNonEmpty(String str, String message)
Checks that the provided string is not empty.static <T> Collection<T>
requireNonEmpty(Collection<T> col)
Checks that the provided collection is not empty.static <T> Collection<T>
requireNonEmpty(Collection<T> col, String message)
Checks that the provided collection is not empty.static String
requireNullOrNonEmpty(String str)
Checks that the provided string is either null or not empty.static String
requireNullOrNonEmpty(String str, String message)
Checks that the provided string is either null or not empty.static <T> Collection<T>
requireNullOrNonEmpty(Collection<T> col)
Checks that the provided collection is either null or not empty.static <T> Collection<T>
requireNullOrNonEmpty(Collection<T> col, String message)
Checks that the provided collection is either null or not empty.
-
-
-
Method Detail
-
requireNonEmpty
public static String requireNonEmpty(String str)
Checks that the provided string is not empty.- Parameters:
str
- the string to check- Returns:
- the same string
- Throws:
NullPointerException
- if the provided string isnull
IllegalArgumentException
- if the provided string is empty
-
requireNonEmpty
public static String requireNonEmpty(String str, String message)
Checks that the provided string is not empty.- Parameters:
str
- the string to checkmessage
- the exception message to use- Returns:
- the same string
- Throws:
NullPointerException
- if the provided string isnull
IllegalArgumentException
- if the provided string is empty
-
requireNonEmpty
public static <T> Collection<T> requireNonEmpty(Collection<T> col)
Checks that the provided collection is not empty.- Type Parameters:
T
- the contained type of the collection- Parameters:
col
- the collection to check- Returns:
- the same collection
- Throws:
NullPointerException
- if the provided collection isnull
IllegalArgumentException
- if the provided collection is empty
-
requireNonEmpty
public static <T> Collection<T> requireNonEmpty(Collection<T> col, String message)
Checks that the provided collection is not empty.- Type Parameters:
T
- the contained type of the collection- Parameters:
col
- the collection to checkmessage
- the exception message to use- Returns:
- the same collection
- Throws:
NullPointerException
- if the provided collection isnull
IllegalArgumentException
- if the provided collection is empty
-
requireNullOrNonEmpty
public static String requireNullOrNonEmpty(String str)
Checks that the provided string is either null or not empty.- Parameters:
str
- the string to check- Returns:
- the same string
- Throws:
IllegalArgumentException
- if the provided string is not null and is empty
-
requireNullOrNonEmpty
public static String requireNullOrNonEmpty(String str, String message)
Checks that the provided string is either null or not empty.- Parameters:
str
- the string to checkmessage
- the exception message to use- Returns:
- the same string
- Throws:
IllegalArgumentException
- if the provided string is not null and is empty
-
requireNullOrNonEmpty
public static <T> Collection<T> requireNullOrNonEmpty(Collection<T> col)
Checks that the provided collection is either null or not empty.- Type Parameters:
T
- the contained type of the collection- Parameters:
col
- the collection to check- Returns:
- the same collection
- Throws:
IllegalArgumentException
- if the provided string is not null and is empty
-
requireNullOrNonEmpty
public static <T> Collection<T> requireNullOrNonEmpty(Collection<T> col, String message)
Checks that the provided collection is either null or not empty.- Type Parameters:
T
- the contained type of the collection- Parameters:
col
- the collection to checkmessage
- the exception message to use- Returns:
- the same collection
- Throws:
IllegalArgumentException
- if the provided string is not null and is empty
-
-