T
- the object type.public interface AssertThatCastableObject<T> extends AssertThatObject<T>
Modifier and Type | Method and Description |
---|---|
<P extends T> |
as(Class<P> clazz)
Cast the received value into a sub-class of the receiver, before applying
the matcher.
|
<P> AssertThatCastableObject<P> |
as(Class<P> targetClass,
Function<T,P> converter)
Convert a received object into another one, based on a passed converter.
|
<P extends T> AssertThatObject<P> as(Class<P> clazz)
For example, we have Object myNumber =...;
which is known to
be an Integer
. It is possible to convert it by using :
assertThat(myNumber).as(Integer.class).is(10);
P
- The subtype for the conversionclazz
- the target classthe assertion on the result of the
conversion
.<P> AssertThatCastableObject<P> as(Class<P> targetClass, Function<T,P> converter)
For example, we have String myString =...;
which is known to
be a String
representing an Integer
. It is
possible to convert it by using:
assertThat(myString).as(Integer.class, Integer::valueOf).is(1);
P
- the target typetargetClass
- he target classconverter
- the converter to be used to converter the object to the target
class.the assertion on the result of
the conversion
.Copyright © 2015 Powerunit. All rights reserved.