Package org.eolang
Class Expect<T>
- java.lang.Object
-
- org.eolang.Expect<T>
-
- Type Parameters:
T- The type of result
public class Expect<T> extends Object
This wrapper helps us explain our expectations in an error message that we throw.- Since:
- 0.41.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExpect.IntTransform Expect to Integer.static classExpect.NaturalTransform Expect to Natural number.static classExpect.NumberTransform Expect to Number.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Expect<Phi>at(Phi phi, String attr)Starting point.Tit()Return it.Expect<T>must(Function<T,Boolean> fun)Assert on it.Expect<T>otherwise(String message)Fail with this message otherwise.<R> Expect<R>that(Function<T,R> fun)Assert that it passes.
-
-
-
Method Detail
-
at
public static Expect<Phi> at(Phi phi, String attr)
Starting point.- Parameters:
phi- The objectattr- Attribute name- Returns:
- Expect pipeline
-
that
public <R> Expect<R> that(Function<T,R> fun)
Assert that it passes.- Type Parameters:
R- Type of result- Parameters:
fun- The function to transform- Returns:
- New object
-
otherwise
public Expect<T> otherwise(String message)
Fail with this message otherwise.- Parameters:
message- The error message- Returns:
- Next object
-
must
public Expect<T> must(Function<T,Boolean> fun)
Assert on it.- Parameters:
fun- The check.- Returns:
- Next object
-
it
public T it()
Return it.- Returns:
- The token
-
-