Package htsjdk.utils
Class ValidationUtils
java.lang.Object
htsjdk.utils.ValidationUtils
Simple functions that streamline the checking of values.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isNonEmpty
(Collection<?> collection) Checks that aCollection
is notnull
and that it is not empty.static String
Checks that aString
is notnull
and that it is not empty.static String
Checks that aString
is notnull
and that it is not empty.static <I,
T extends Collection<I>>
TnonEmpty
(T collection) Checks that aCollection
is notnull
and that it is not empty.static <T extends Collection<?>>
TChecks that aCollection
is notnull
and that it is not empty.static <T> T
nonNull
(T object) Checks that an Objectobject
is not null and returns the same object or throws anIllegalArgumentException
static <T> T
static <T> T
static void
validateArg
(boolean condition, String msg) static void
validateArg
(boolean condition, Supplier<String> msg)
-
Constructor Details
-
ValidationUtils
public ValidationUtils()
-
-
Method Details
-
nonNull
public static <T> T nonNull(T object) Checks that an Objectobject
is 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 aCollection
is notnull
and 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 aCollection
is notnull
and 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 aString
is notnull
and 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 aString
is notnull
and 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 aCollection
is notnull
and 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
-