10Duke Java Core
Loading...
Searching...
No Matches
tenduke.sdk.core.model.Guard Class Reference

Detailed Description

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.
 

Member Function Documentation

◆ requireNonEmptyCollection() [1/2]

static void tenduke.sdk.core.model.Guard.requireNonEmptyCollection ( final Collection<?> collection,
final String message )
static

Asserts that the given collection is not null and not empty: throws an IllegalArgumentException with provided message if the collection does not qualify.

Parameters
collectionThe collection to inspect.
messageThe message to set for the IllegalArgumentException in case the collection is null or empty.

◆ requireNonEmptyCollection() [2/2]

static void tenduke.sdk.core.model.Guard.requireNonEmptyCollection ( final Collection<?> collection,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
collectionThe collection to inspect.
messageThe message to set for the runtime exception in case the collection is null or empty.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNonEmptyMap() [1/2]

static void tenduke.sdk.core.model.Guard.requireNonEmptyMap ( final Map<?, ?> map,
final String message )
static

Asserts that the given Map is not null and not empty: throws an IllegalArgumentException with provided message if the Map does not qualify.

Parameters
mapThe Map to inspect.
messageThe message to set for the IllegalArgumentException in case the Map is null or empty.

◆ requireNonEmptyMap() [2/2]

static void tenduke.sdk.core.model.Guard.requireNonEmptyMap ( final Map<?, ?> map,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
mapThe Map to inspect.
messageThe message to set for the runtime exception in case the Map is null or empty.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNonNull() [1/2]

static void tenduke.sdk.core.model.Guard.requireNonNull ( final Object value,
final String message )
static

Asserts that the given value is not null: throws an IllegalArgumentException with provided message if the value is null.

Parameters
valueThe value to test for null.
messageThe message to set for the IllegalArgumentException in case the value is null.

◆ requireNonNull() [2/2]

static void tenduke.sdk.core.model.Guard.requireNonNull ( final Object value,
final String message,
final Function< String, RuntimeException > exceptionProvider )
static

Asserts that the given value is not null: throws a caller provided exception with provided message if the value is null.

Parameters
valueThe value to test for null.
messageThe message to set for the runtime exception in case the value is null.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNotBlank() [1/2]

static void tenduke.sdk.core.model.Guard.requireNotBlank ( final CharSequence value,
final String message )
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.

Parameters
valueThe value to test for null.
messageThe message to set for the IllegalArgumentException in case the value is a blank String.

◆ requireNotBlank() [2/2]

static void tenduke.sdk.core.model.Guard.requireNotBlank ( final CharSequence value,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
valueThe value to test for null.
messageThe message to set for the exception in case the value is a blank String.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNotBlankString() [1/2]

static void tenduke.sdk.core.model.Guard.requireNotBlankString ( final Optional< String > optValue,
final String message )
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.

Parameters
optValueThe value to test if it is blank.
messageThe message to set for the IllegalArgumentException in case the value is a blank String.

◆ requireNotBlankString() [2/2]

static void tenduke.sdk.core.model.Guard.requireNotBlankString ( final Optional< String > optValue,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
optValueThe value to test if it is blank.
messageThe message to set for the runtime exception in case the value is a blank String.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNotBlankUri() [1/3]

static void tenduke.sdk.core.model.Guard.requireNotBlankUri ( final Optional< URI > optUri,
final String message )
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.

Parameters
optUriThe value to test for null.
messageThe message to set for the IllegalArgumentException in case the value is a blank URI.

◆ requireNotBlankUri() [2/3]

static void tenduke.sdk.core.model.Guard.requireNotBlankUri ( final Optional< URI > optUri,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
optUriThe value to test for null.
messageThe message to set for the runtime exception in case the value is a blank URI.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireNotBlankUri() [3/3]

static void tenduke.sdk.core.model.Guard.requireNotBlankUri ( final URI uri,
final String message )
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.

Parameters
uriThe value to test for null.
messageThe message to set for the IllegalArgumentException if the value is a blank URI.

◆ requireUniqueCollectionElement()

static void tenduke.sdk.core.model.Guard.requireUniqueCollectionElement ( final Object value,
final Collection<?> collection,
final String message )
static

Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null.

Parameters
valueThe value to test for uniqueness in the collection.
collectionThe collection to inspect, check if contains value.
messageThe message to set for the IllegalArgumentException in case the value is already contained in the collection.

◆ requireUniqueCollectionElementArg()

static void tenduke.sdk.core.model.Guard.requireUniqueCollectionElementArg ( final Object value,
final Collection<?> collection,
final String message,
final Function< String, RuntimeException > exceptionProvider )
static

Asserts that the given collection does not contains the value: throws an IllegalArgumentException with provided message if the value is null.

Parameters
valueThe value to test for uniqueness in the collection.
collectionThe collection to inspect, check if contains value.
messageThe message to set for the IllegalArgumentException in case the value is already contained in the collection.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

◆ requireValidHttpUriScheme() [1/2]

static void tenduke.sdk.core.model.Guard.requireValidHttpUriScheme ( final URI uri,
final String message )
static

Asserts that the given URI has a valid http(s) scheme.

Throws an IllegalArgumentException with provided message if the value is is invalid.

Parameters
uriThe URI to test for having a valid http(s) scheme.
messageThe message to set for the IllegalArgumentException in case the value is invalid.

◆ requireValidHttpUriScheme() [2/2]

static void tenduke.sdk.core.model.Guard.requireValidHttpUriScheme ( final URI uri,
final String message,
final Function< String, RuntimeException > exceptionProvider )
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.

Parameters
uriThe URI to test for having a valid http(s) scheme.
messageThe message to set for the runtime exception in case the value is invalid.
exceptionProviderFunction that creates a runtime exception and sets a message to it.

The documentation for this class was generated from the following file: