Package io.vertx.core
Interface Expectation<V>
-
- All Known Subinterfaces:
HttpResponseExpectation
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Expectation<V>
An expectation, very much like a predicate with the ability to provide a meaningful description of the failure. Expectation can be used withFuture.expecting(Expectation)
.- Author:
- Julien Viet
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Expectation<V>
and(Expectation<? super V> other)
Returned an expectation succeeding when this expectation and theother
expectation succeeds.default Throwable
describe(V value)
Turn an invalidvalue
into an exception describing the failure, the default implementation returns a generic exception.default Expectation<V>
or(Expectation<? super V> other)
Returned an expectation succeeding when this expectation or theother
expectation succeeds.boolean
test(V value)
Check thevalue
, this should be side effect free, the expectation should either succeed returningtrue
or fail returningfalse
.default Expectation<V>
wrappingFailure(java.util.function.BiFunction<V,Throwable,Throwable> descriptor)
Returns a new expectation with the same predicate and a customized errordescriptor
.
-
-
-
Method Detail
-
test
boolean test(V value)
Check thevalue
, this should be side effect free, the expectation should either succeed returningtrue
or fail returningfalse
.- Parameters:
value
- the checked value
-
and
default Expectation<V> and(Expectation<? super V> other)
Returned an expectation succeeding when this expectation and theother
expectation succeeds.- Parameters:
other
- the other expectation- Returns:
- an expectation that is a logical and of this and
other
-
or
default Expectation<V> or(Expectation<? super V> other)
Returned an expectation succeeding when this expectation or theother
expectation succeeds.- Parameters:
other
- the other expectation- Returns:
- an expectation that is a logical or of this and
other
-
describe
default Throwable describe(V value)
Turn an invalidvalue
into an exception describing the failure, the default implementation returns a generic exception.- Parameters:
value
- the value to describe- Returns:
- a meaningful exception
-
wrappingFailure
default Expectation<V> wrappingFailure(java.util.function.BiFunction<V,Throwable,Throwable> descriptor)
Returns a new expectation with the same predicate and a customized errordescriptor
.- Parameters:
descriptor
- the function describing the error- Returns:
- a new expectation describing the error with
descriptor
-
-