Package htsjdk.utils
Class ValidationUtils
java.lang.Object
htsjdk.utils.ValidationUtils
Simple functions that streamline the checking of values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisNonEmpty(Collection<?> collection) Checks that aCollectionis notnulland that it is not empty.static StringChecks that aStringis notnulland that it is not empty.static StringChecks that aStringis notnulland that it is not empty.static <I,T extends Collection<I>>
TnonEmpty(T collection) Checks that aCollectionis notnulland that it is not empty.static <T extends Collection<?>>
TChecks that aCollectionis notnulland that it is not empty.static <T> TnonNull(T object) Checks that an Objectobjectis not null and returns the same object or throws anIllegalArgumentExceptionstatic <T> Tstatic <T> Tstatic voidvalidateArg(boolean condition, String msg) static voidvalidateArg(boolean condition, Supplier<String> msg)
-
Constructor Details
-
ValidationUtils
public ValidationUtils()
-
-
Method Details
-
nonNull
public static <T> T nonNull(T object) Checks that an Objectobjectis not null and returns the same object or throws anIllegalArgumentException- Parameters:
object- any Object- Returns:
- the same object
- Throws:
IllegalArgumentException- if ao == null
-
nonNull
- Parameters:
object- any ObjectnameOfObject- the name of the object that is being checked for null. ( is used in the exception thrown wheno == null.)- Returns:
- the same object
- Throws:
IllegalArgumentException- if ao == null
-
nonNull
- Parameters:
object- any Objectmessage- the text message that would be passed to the exception thrown wheno == null.- Returns:
- the same object
- Throws:
IllegalArgumentException- if ao == null
-
nonEmpty
Checks that aCollectionis notnulland that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws anIllegalArgumentException- Parameters:
collection- any CollectionnameOfObject- the name of the object that is being checked for non-emptiness. ( is used in the exception thrown wheno.isEmpty().)- Returns:
- the original collection
- Throws:
IllegalArgumentException- if collection is null or empty
-
isNonEmpty
Checks that aCollectionis notnulland that it is not empty. If it's non-null and non-empty it returns the true- Parameters:
collection- any Collection- Returns:
- true if the collection exists and has elements
-
nonEmpty
Checks that aStringis notnulland that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws anIllegalArgumentException- Parameters:
string- any StringnameOfObject- a message to include in the output- Returns:
- the original string
- Throws:
IllegalArgumentException- if string is null or empty
-
nonEmpty
Checks that aStringis notnulland that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws anIllegalArgumentException- Parameters:
string- any String- Returns:
- the original string
- Throws:
IllegalArgumentException- if string is null or empty
-
nonEmpty
Checks that aCollectionis notnulland that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws anIllegalArgumentException- Parameters:
collection- any Collection- Returns:
- the original collection
- Throws:
IllegalArgumentException- if collection is null or empty
-
validateArg
-
validateArg
-