Package htsjdk.utils

# Class ValidationUtils

java.lang.Object
htsjdk.utils.ValidationUtils

public class ValidationUtils extends Object
Simple functions that streamline the checking of values.

## Constructor Summary

Constructors
Constructor
Description
`ValidationUtils()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`isNonEmpty(Collection<?> collection)`
Checks that a `Collection` is not `null` and that it is not empty.
`static String`
`nonEmpty(String string)`
Checks that a `String` is not `null` and that it is not empty.
`static String`
`nonEmpty(String string, String nameOfObject)`
Checks that a `String` is not `null` and that it is not empty.
`static <I, T extends Collection<I>>
T`
`nonEmpty(T collection)`
Checks that a `Collection` is not `null` and that it is not empty.
`static <T extends Collection<?>>
T`
`nonEmpty(T collection, String nameOfObject)`
Checks that a `Collection` is not `null` and that it is not empty.
`static <T> T`
`nonNull(T object)`
Checks that an Object `object` is not null and returns the same object or throws an `IllegalArgumentException`
`static <T> T`
`nonNull(T object, String nameOfObject)`
Checks that an `Object` is not `null` and returns the same object or throws an `IllegalArgumentException`
`static <T> T`
`nonNull(T object, Supplier<String> message)`
Checks that an `Object` is not `null` and returns the same object or throws an `IllegalArgumentException`
`static void`
`validateArg(boolean condition, String msg)`
`static void`
`validateArg(boolean condition, Supplier<String> msg)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ValidationUtils

public ValidationUtils()

## Method Details

### nonNull

public static <T> T nonNull(T object)
Checks that an Object `object` is not null and returns the same object or throws an `IllegalArgumentException`

Parameters:
  `object` - any Object
Returns:
  the same object
Throws:
  `IllegalArgumentException` - if a `o == null`

### nonNull

public static <T> T nonNull(T object, String nameOfObject)
Checks that an `Object` is not `null` and returns the same object or throws an `IllegalArgumentException`

Parameters:
  `object` - any Object
  `nameOfObject` - the name of the object that is being checked for null. ( is used in the exception thrown when `o == null`.)
Returns:
  the same object
Throws:
  `IllegalArgumentException` - if a `o == null`

### nonNull

public static <T> T nonNull(T object, Supplier<String> message)
Checks that an `Object` is not `null` and returns the same object or throws an `IllegalArgumentException`

Parameters:
  `object` - any Object
  `message` - the text message that would be passed to the exception thrown when `o == null`.
Returns:
  the same object
Throws:
  `IllegalArgumentException` - if a `o == null`

### nonEmpty

public static <T extends Collection<?>> T nonEmpty(T collection, String nameOfObject)
Checks that a `Collection` is not `null` and that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws an `IllegalArgumentException`

Parameters:
  `collection` - any Collection
  `nameOfObject` - the name of the object that is being checked for non-emptiness. ( is used in the exception thrown when `o.isEmpty()`.)
Returns:
  the original collection
Throws:
  `IllegalArgumentException` - if collection is null or empty

### isNonEmpty

public static boolean isNonEmpty(Collection<?> collection)
Checks that a `Collection` is not `null` 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

public static String nonEmpty(String string, String nameOfObject)
Checks that a `String` is not `null` and that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws an `IllegalArgumentException`

Parameters:
  `string` - any String
  `nameOfObject` - a message to include in the output
Returns:
  the original string
Throws:
  `IllegalArgumentException` - if string is null or empty

### nonEmpty

public static String nonEmpty(String string)
Checks that a `String` is not `null` and that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws an `IllegalArgumentException`

Parameters:
  `string` - any String
Returns:
  the original string
Throws:
  `IllegalArgumentException` - if string is null or empty

### nonEmpty

public static <I, T extends Collection<I>> T nonEmpty(T collection)
Checks that a `Collection` is not `null` and that it is not empty. If it's non-null and non-empty it returns the input, otherwise it throws an `IllegalArgumentException`

Parameters:
  `collection` - any Collection
Returns:
  the original collection
Throws:
  `IllegalArgumentException` - if collection is null or empty

### validateArg

public static void validateArg(boolean condition, String msg)

### validateArg

public static void validateArg(boolean condition, Supplier<String> msg)