10Duke Java Core
|
Utility class to help with argument and data object assertions.
Assertion methods include for example checks for not null, empty, blank, unique element and scheme validation.
Static Public Member Functions | |
static void | requireNonNull (final Object value, final String message) |
Asserts that the given value is not null: throws an IllegalArgumentException with provided message if the value is null. | |
static void | requireNonNull (final Object value, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given value is not null: throws a caller provided exception with provided message if the value is null. | |
static void | requireNotBlank (final CharSequence value, final String message) |
Asserts that the given value is not a blank String: throws an IllegalArgumentException with provided message if the value is blank. | |
static void | requireNotBlank (final CharSequence value, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given value is not a blank String: throws a caller provided runtime exception with provided message if the value is blank. | |
static void | requireNotBlankString (final Optional< String > optValue, final String message) |
Asserts that the given value is not a blank String: throws an IllegalArgumentException with provided message if the value is blank. | |
static void | requireNotBlankString (final Optional< String > optValue, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given value is not a blank String: throws a caller provided exception with provided message if the value is blank. | |
static void | requireNotBlankUri (final Optional< URI > optUri, final String message) |
Asserts that the given value is not a blank String representation of an URI: throws an IllegalArgumentException with provided message if the value is blank. | |
static void | requireNotBlankUri (final Optional< URI > optUri, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given value is not a blank String representation of an URI: throws a caller provided exception with provided message if the value is blank. | |
static void | requireNotBlankUri (final URI uri, final String message) |
Asserts that the given value is not a blank String representation of an URI: throws an IllegalArgumentException with provided message if the value is blank. | |
static void | requireValidHttpUriScheme (final URI uri, final String message) |
Asserts that the given URI has a valid http(s) scheme. | |
static void | requireValidHttpUriScheme (final URI uri, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given URI has a valid http(s) scheme. | |
static void | requireUniqueCollectionElement (final Object value, final Collection<?> collection, final String message) |
Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null. | |
static void | requireUniqueCollectionElementArg (final Object value, final Collection<?> collection, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null. | |
static void | requireNonEmptyCollection (final Collection<?> collection, final String message) |
Asserts that the given collection is not null and not empty: throws an IllegalArgumentException with provided message if the collection does not qualify. | |
static void | requireNonEmptyCollection (final Collection<?> collection, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given collection is not null and not empty: throws a caller defined exception with provided message if the collection does not qualify. | |
static void | requireNonEmptyMap (final Map<?, ?> map, final String message) |
Asserts that the given Map is not null and not empty: throws an IllegalArgumentException with provided message if the Map does not qualify. | |
static void | requireNonEmptyMap (final Map<?, ?> map, final String message, final Function< String, RuntimeException > exceptionProvider) |
Asserts that the given Map is not null and not empty: throws a caller defined exception with provided message if the Map does not qualify. | |
|
static |
Asserts that the given collection is not null and not empty: throws an IllegalArgumentException with provided message if the collection does not qualify.
collection | The collection to inspect. |
message | The message to set for the IllegalArgumentException in case the collection is null or empty. |
|
static |
Asserts that the given collection is not null and not empty: throws a caller defined exception with provided message if the collection does not qualify.
collection | The collection to inspect. |
message | The message to set for the runtime exception in case the collection is null or empty. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given Map is not null and not empty: throws an IllegalArgumentException with provided message if the Map does not qualify.
map | The Map to inspect. |
message | The message to set for the IllegalArgumentException in case the Map is null or empty. |
|
static |
Asserts that the given Map is not null and not empty: throws a caller defined exception with provided message if the Map does not qualify.
map | The Map to inspect. |
message | The message to set for the runtime exception in case the Map is null or empty. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given value is not null: throws an IllegalArgumentException with provided message if the value is null.
value | The value to test for null. |
message | The message to set for the IllegalArgumentException in case the value is null. |
|
static |
Asserts that the given value is not null: throws a caller provided exception with provided message if the value is null.
value | The value to test for null. |
message | The message to set for the runtime exception in case the value is null. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given value is not a blank String: throws an IllegalArgumentException with provided message if the value is blank.
Is blank is tested by: CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
value | The value to test for null. |
message | The message to set for the IllegalArgumentException in case the value is a blank String. |
|
static |
Asserts that the given value is not a blank String: throws a caller provided runtime exception with provided message if the value is blank.
Is blank is tested by: CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
value | The value to test for null. |
message | The message to set for the exception in case the value is a blank String. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given value is not a blank String: throws an IllegalArgumentException with provided message if the value is blank.
Is blank is tested by: Optional.isPresent and CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
optValue | The value to test if it is blank. |
message | The message to set for the IllegalArgumentException in case the value is a blank String. |
|
static |
Asserts that the given value is not a blank String: throws a caller provided exception with provided message if the value is blank.
Is blank is tested by: Optional.isPresent and CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
optValue | The value to test if it is blank. |
message | The message to set for the runtime exception in case the value is a blank String. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given value is not a blank String representation of an URI: throws an IllegalArgumentException with provided message if the value is blank.
Is blank is tested by: Optional.isPresent and CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
optUri | The value to test for null. |
message | The message to set for the IllegalArgumentException in case the value is a blank URI. |
|
static |
Asserts that the given value is not a blank String representation of an URI: throws a caller provided exception with provided message if the value is blank.
Is blank is tested by: Optional.isPresent and CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
optUri | The value to test for null. |
message | The message to set for the runtime exception in case the value is a blank URI. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given value is not a blank String representation of an URI: throws an IllegalArgumentException with provided message if the value is blank.
Is blank is tested by: CharSequence is empty (""), null or contains whitespace only. See: Apache Commons Lang3 StringUtils for more details about testing for blank.
uri | The value to test for null. |
message | The message to set for the IllegalArgumentException if the value is a blank URI. |
|
static |
Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null.
value | The value to test for uniqueness in the collection. |
collection | The collection to inspect, check if contains value. |
message | The message to set for the IllegalArgumentException in case the value is already contained in the collection. |
|
static |
Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null.
value | The value to test for uniqueness in the collection. |
collection | The collection to inspect, check if contains value. |
message | The message to set for the IllegalArgumentException in case the value is already contained in the collection. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |
|
static |
Asserts that the given URI has a valid http(s) scheme.
Throws an IllegalArgumentException with provided message if the value is is invalid.
uri | The URI to test for having a valid http(s) scheme. |
message | The message to set for the IllegalArgumentException in case the value is invalid. |
|
static |
Asserts that the given URI has a valid http(s) scheme.
Throws a caller defined exception with provided message if the value is is invalid.
uri | The URI to test for having a valid http(s) scheme. |
message | The message to set for the runtime exception in case the value is invalid. |
exceptionProvider | Function that creates a runtime exception and sets a message to it. |