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
  • Constructor Details

    • Expect

      public Expect(String subj, Supplier<T> supplier)
      Ctor.
      Parameters:
      subj - The subject
      supplier - The supplier
  • Method Details

    • at

      public static Expect<Phi> at(Phi phi, String attr)
      Starting point.
      Parameters:
      phi - The object
      attr - 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