Package net.morimekta.providence.util
Class MessageValidation.PredicateExpectation<Value>
- java.lang.Object
-
- net.morimekta.providence.util.MessageValidation.PredicateExpectation<Value>
-
- Type Parameters:
Value
- The value type being validated.
- All Implemented Interfaces:
MessageValidation.Expectation<Value>
,MessageValidation.SimpleExpectation<Value>
- Enclosing class:
- MessageValidation<M extends PMessage<M>,E extends java.lang.Exception>
public static final class MessageValidation.PredicateExpectation<Value> extends java.lang.Object implements MessageValidation.SimpleExpectation<Value>
Check some value based on a simple predicate.
-
-
Constructor Summary
Constructors Constructor Description PredicateExpectation(java.util.function.Predicate<Value> predicate, java.lang.String failureMessage)
Create a predicate based expectation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
test(Value value)
Test the value.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.util.MessageValidation.SimpleExpectation
test
-
-
-
-
Constructor Detail
-
PredicateExpectation
public PredicateExpectation(java.util.function.Predicate<Value> predicate, java.lang.String failureMessage)
Create a predicate based expectation. The expectation is met if the predicate evaluates to 'true'. And will throwIllegalStateException
if not.- Parameters:
predicate
- The value predicate.failureMessage
- The message of the thrown exception.
-
-
Method Detail
-
test
public void test(Value value)
Test the value.- Specified by:
test
in interfaceMessageValidation.SimpleExpectation<Value>
- Parameters:
value
- The value to test.- Throws:
java.lang.IllegalStateException
- if the value does not meet the predicate expectation.
-
-