Class Guard
java.lang.Object
de.team33.patterns.proving.kerberos.Guard
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TnonNull(T candidate) Returns a given candidate if it is notnull.static <T> TReturns a given candidate if it is notnull.static voidprove(boolean condition) Proves that the given condition istrue.static voidProves that the given condition istrue.static <E extends Exception>
voidProves that the given condition istrue.static <T> TReturns a given candidate if it meets the given condition.static <T> TReturns a given candidate if it meets the given condition.static <T,E extends Exception>
Tproved(T candidate, Predicate<? super T> condition, Function<? super T, String> toMessage, Function<? super String, E> toException) Returns a given candidate if it meets the given condition.
-
Method Details
-
prove
public static void prove(boolean condition) Proves that the given condition istrue. Otherwise, throws anIllegalStateExceptionwith a default message. -
prove
Proves that the given condition istrue. Otherwise, throws anIllegalStateExceptionwith a message supplied by toMessage. -
prove
public static <E extends Exception> void prove(boolean condition, Supplier<String> toMessage, Function<? super String, E> toException) throws EProves that the given condition istrue. Otherwise, throws an exception provided by toException with a message supplied by toMessage.- Throws:
E extends Exception
-
proved
Returns a given candidate if it meets the given condition. Otherwise, throws an exception with a default message.- Type Parameters:
T- The type of candidate.- Throws:
IllegalArgumentException- if the candidate does not meet the condition.
-
proved
public static <T> T proved(T candidate, Predicate<? super T> condition, Function<? super T, String> toMessage) Returns a given candidate if it meets the given condition. Otherwise, throws an exception with a message supplied by toMessage.- Type Parameters:
T- The type of candidate.- Throws:
IllegalArgumentException- if the candidate does not meet the condition.
-
proved
public static <T,E extends Exception> T proved(T candidate, Predicate<? super T> condition, Function<? super T, String> toMessage, Function<? super String, throws EE> toException) Returns a given candidate if it meets the given condition. Otherwise, throws an exception provided by toException with a message supplied by toMessage.- Type Parameters:
T- The type of candidate.E- The type of exception.- Throws:
E- if the candidate does not meet the condition.
-
nonNull
public static <T> T nonNull(T candidate) Returns a given candidate if it is notnull. Otherwise, throws an exception with a default message.- Type Parameters:
T- The type of candidate.- Throws:
NullPointerException- if the candidate isnull.
-
nonNull
Returns a given candidate if it is notnull. Otherwise, throws an exception with a message supplied by toMessage.- Type Parameters:
T- The type of candidate.- Throws:
NullPointerException- if the candidate isnull.
-