- java.lang.Object
-
- dk.cloudcreate.essentials.shared.FailFast
-
public final class FailFast extends Object
Collection ofObjects.requireNonNull(Object)replacement methods
-
-
Constructor Summary
Constructors Constructor Description FailFast()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidrequireFalse(boolean mustBeFalse, String message)Assert that the boolean valuemustBeTrueistrue.static <T> TrequireMustBeInstanceOf(Object objectThatMustBeAnInstanceOf, Class<?> mustBeAnInstanceOf, String message)Assert that theobjectThatMustBeAnInstanceOfis an instance ofmustBeAnInstanceOfparameter, if not thenIllegalArgumentExceptionis thrownstatic <T> TrequireMustBeInstanceOf(Object objectThatMustBeAnInstanceOf, Class<T> mustBeAnInstanceOf)Assert that theobjectThatMustBeAnInstanceOfis an instance ofmustBeAnInstanceOfparameter, if not thenIllegalArgumentExceptionis thrownstatic <T extends CharSequence>
TrequireNonBlank(T characterStreamThatMustNotBeEmptyOrNull, String message)Assert that thecharacterStreamThatMustNotBeEmptyOrNullis NOT null AND NOT empty/blank, otherwise aIllegalArgumentExceptionis thrownstatic Object[]requireNonEmpty(Object[] items, String message)static <T> List<T>requireNonEmpty(List<T> items, String message)static <K,V>
Map<K,V>requireNonEmpty(Map<K,V> items, String message)static <T> Set<T>requireNonEmpty(Set<T> items, String message)static <T> TrequireNonNull(T objectThatMayNotBeNull)Assert that theobjectThatMayNotBeNullis NOT null.static <T> TrequireNonNull(T objectThatMayNotBeNull, String message)Assert that theobjectThatMayNotBeNullis NOT null.static <T> TrequireNonNull(T objectThatMayNotBeNull, String message, Object... messageArguments)Assert that theobjectThatMayNotBeNullis NOT null.static voidrequireTrue(boolean mustBeTrue, String message)Assert that the boolean valuemustBeTrueistrue.
-
-
-
Method Detail
-
requireMustBeInstanceOf
public static <T> T requireMustBeInstanceOf(Object objectThatMustBeAnInstanceOf, Class<T> mustBeAnInstanceOf)
Assert that theobjectThatMustBeAnInstanceOfis an instance ofmustBeAnInstanceOfparameter, if not thenIllegalArgumentExceptionis thrown- Type Parameters:
T- the type of class that theobjectThatMustBeAnInstanceOfmust be an instance of- Parameters:
objectThatMustBeAnInstanceOf- the object that must be an instance ofmustBeAnInstanceOfparametermustBeAnInstanceOf- the type that theobjectThatMustBeAnInstanceOfparameter must be an instance of- Returns:
- the "objectThatMustBeAnInstanceOf" IF it is of the right type
-
requireMustBeInstanceOf
public static <T> T requireMustBeInstanceOf(Object objectThatMustBeAnInstanceOf, Class<?> mustBeAnInstanceOf, String message)
Assert that theobjectThatMustBeAnInstanceOfis an instance ofmustBeAnInstanceOfparameter, if not thenIllegalArgumentExceptionis thrown- Type Parameters:
T- the type of class that theobjectThatMustBeAnInstanceOfmust be an instance of- Parameters:
objectThatMustBeAnInstanceOf- the object that must be an instance ofmustBeAnInstanceOfparametermustBeAnInstanceOf- the type that theobjectThatMustBeAnInstanceOfparameter must be an instance ofmessage- the optional message that will become the message of theIllegalArgumentExceptionin case theobjectThatMustBeAnInstanceOfis NOT an instance ofmustBeAnInstanceOf- Returns:
- the "objectThatMustBeAnInstanceOf" IF it is of the right type
-
requireNonNull
public static <T> T requireNonNull(T objectThatMayNotBeNull, String message)Assert that theobjectThatMayNotBeNullis NOT null. If it's null then anIllegalArgumentExceptionis thrown- Type Parameters:
T- the type of theobjectThatMayNotBeNull- Parameters:
objectThatMayNotBeNull- the object that must NOT be nullmessage- the optional message that will become the message of theIllegalArgumentExceptionin case theobjectThatMayNotBeNullis NULL- Returns:
- the "objectThatMayNotBeNull" IF it's not null
-
requireNonBlank
public static <T extends CharSequence> T requireNonBlank(T characterStreamThatMustNotBeEmptyOrNull, String message)
Assert that thecharacterStreamThatMustNotBeEmptyOrNullis NOT null AND NOT empty/blank, otherwise aIllegalArgumentExceptionis thrown- Type Parameters:
T- the type of thecharacterStreamThatMustNotBeEmptyOrNull- Parameters:
characterStreamThatMustNotBeEmptyOrNull- the object that must NOT be null or emptymessage- the optional message that will become the message of theIllegalArgumentExceptionin case thecharacterStreamThatMustNotBeEmptyOrNullis NULL- Returns:
- the "characterStreamThatMustNotBeEmptyOrNull" IF it's not null
-
requireNonNull
public static <T> T requireNonNull(T objectThatMayNotBeNull, String message, Object... messageArguments)Assert that theobjectThatMayNotBeNullis NOT null. If it's null then anIllegalArgumentExceptionis thrown
Short handle for callingrequireNonNull(someObjectThatMustNotBeNull, m("Message with {} placeholder", someMessageObject))- (seeMessageFormatter.msg(String, Object...))- Type Parameters:
T- the type of theobjectThatMayNotBeNull- Parameters:
objectThatMayNotBeNull- the object that must NOT be nullmessage- the optional message that will become the message of theIllegalArgumentExceptionin case theobjectThatMayNotBeNullis NULLmessageArguments- any placeholders for the message (seeMessageFormatter.msg(String, Object...))- Returns:
- the "objectThatMayNotBeNull" IF it's not null
-
requireNonNull
public static <T> T requireNonNull(T objectThatMayNotBeNull)
Assert that theobjectThatMayNotBeNullis NOT null. If it's null then anIllegalArgumentExceptionis thrown- Type Parameters:
T- the type of theobjectThatMayNotBeNull- Parameters:
objectThatMayNotBeNull- the object that must NOT be null- Returns:
- the "objectThatMayNotBeNull" IF it's not null
-
requireTrue
public static void requireTrue(boolean mustBeTrue, String message)- Parameters:
mustBeTrue- boolean value that we will assert MUST be TRUEmessage- the NON optional message that will become the message of theIllegalArgumentExceptionin case themustBeTrueis FALSE
-
requireFalse
public static void requireFalse(boolean mustBeFalse, String message)- Parameters:
mustBeFalse- boolean value that we will assert MUST be FALSEmessage- the NON optional message that will become the message of theIllegalArgumentExceptionin case themustBeFalseis TRUE
-
-