Package fj.data

Class Validation.FailProjection<E,T>

java.lang.Object
fj.data.Validation.FailProjection<E,T>
All Implemented Interfaces:
Iterable<E>
Enclosing class:
Validation<E,T>

public static final class Validation.FailProjection<E,T> extends Object implements Iterable<E>
A failing projection of a validation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Validation<E,T>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <A> Validation<A,T>
    apply(Validation<F<E,A>,T> v)
    Function application on the failing value.
    <A> Validation<A,T>
    bind(F<E,Validation<A,T>> f)
    Binds the given function across this validation's failing value if it has one.
    boolean
    Returns false if this is a success or returns the result of the application of the given function to the failing value.
    failE(F0<String> err)
    Returns the failing value or fails with the given error message.
    Returns the failing value or fails with the given error message.
    Returns None if this is a success or if the given predicate p does not hold for the failing value, otherwise, returns a fail in Some.
    boolean
    Returns true if this is a success or returns the result of the application of the given function to the failing value.
    Executes a side-effect on the failing value if there is one.
    void
    Executes a side-effect on the failing value if there is one.
    Returns an iterator for this projection.
    <A> Validation<A,T>
    map(F<E,A> f)
    Maps the given function across the failing side of this validation.
    on(F<T,E> f)
    The failing value or the application of the given function to the success value.
    orFail(E e)
    Returns the failing value or the given value.
    orFail(F0<E> e)
    Returns the failing value or the given value.
    <A> Validation<A,T>
    Performs a bind across the validation, but ignores the element value in the function.
    Returns a single element array if this is a failing value, otherwise an empty list.
    Returns a single element list if this is a failing value, otherwise an empty list.
    Returns the failing value in Some if there is one, otherwise None.
    Returns a single element stream if this is a failing value, otherwise an empty list.
    Returns the underlying validation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

  • Constructor Details

    • FailProjection

      private FailProjection(Validation<E,T> v)
  • Method Details

    • validation

      public Validation<E,T> validation()
      Returns the underlying validation.
      Returns:
      The underlying validation.
    • failE

      public E failE(F0<String> err)
      Returns the failing value or fails with the given error message.
      Parameters:
      err - The error message to fail with.
      Returns:
      The failing value.
    • failE

      public E failE(String err)
      Returns the failing value or fails with the given error message.
      Parameters:
      err - The error message to fail with.
      Returns:
      The failing value.
    • orFail

      public E orFail(F0<E> e)
      Returns the failing value or the given value.
      Parameters:
      e - The value to return if this is success.
      Returns:
      The failing value or the given value.
    • orFail

      public E orFail(E e)
      Returns the failing value or the given value.
      Parameters:
      e - The value to return if this is success.
      Returns:
      The failing value or the given value.
    • on

      public E on(F<T,E> f)
      The failing value or the application of the given function to the success value.
      Parameters:
      f - The function to execute on the success value.
      Returns:
      The failing value or the application of the given function to the success value.
    • foreach

      public Unit foreach(F<E,Unit> f)
      Executes a side-effect on the failing value if there is one.
      Parameters:
      f - The side-effect to execute.
      Returns:
      The unit value.
    • foreachDoEffect

      public void foreachDoEffect(Effect1<E> f)
      Executes a side-effect on the failing value if there is one.
      Parameters:
      f - The side-effect to execute.
    • map

      public <A> Validation<A,T> map(F<E,A> f)
      Maps the given function across the failing side of this validation.
      Parameters:
      f - The function to map.
      Returns:
      A new validation with the function mapped.
    • bind

      public <A> Validation<A,T> bind(F<E,Validation<A,T>> f)
      Binds the given function across this validation's failing value if it has one.
      Parameters:
      f - The function to bind across this validation.
      Returns:
      A new validation value after binding.
    • sequence

      public <A> Validation<A,T> sequence(Validation<A,T> v)
      Performs a bind across the validation, but ignores the element value in the function.
      Parameters:
      v - The validation value to apply in the final join.
      Returns:
      A new validation value after the final join.
    • filter

      public <A> Option<Validation<E,A>> filter(F<E,Boolean> f)
      Returns None if this is a success or if the given predicate p does not hold for the failing value, otherwise, returns a fail in Some.
      Parameters:
      f - The predicate function to test on this failing value.
      Returns:
      None if this is a success or if the given predicate p does not hold for the failing value, otherwise, returns a fail in Some.
    • apply

      public <A> Validation<A,T> apply(Validation<F<E,A>,T> v)
      Function application on the failing value.
      Parameters:
      v - The validation of the function to apply on the failing value.
      Returns:
      The result of function application in validation.
    • forall

      public boolean forall(F<E,Boolean> f)
      Returns true if this is a success or returns the result of the application of the given function to the failing value.
      Parameters:
      f - The predicate function to test on this failing value.
      Returns:
      true if this is a success or returns the result of the application of the given function to the failing value.
    • exists

      public boolean exists(F<E,Boolean> f)
      Returns false if this is a success or returns the result of the application of the given function to the failing value.
      Parameters:
      f - The predicate function to test on this failing value.
      Returns:
      false if this is a success or returns the result of the application of the given function to the failing value.
    • toList

      public List<E> toList()
      Returns a single element list if this is a failing value, otherwise an empty list.
      Returns:
      A single element list if this is a failing value, otherwise an empty list.
    • toOption

      public Option<E> toOption()
      Returns the failing value in Some if there is one, otherwise None.
      Returns:
      The failing value in Some if there is one, otherwise None.
    • toArray

      public Array<E> toArray()
      Returns a single element array if this is a failing value, otherwise an empty list.
      Returns:
      A single element array if this is a failing value, otherwise an empty list.
    • toStream

      public Stream<E> toStream()
      Returns a single element stream if this is a failing value, otherwise an empty list.
      Returns:
      A single element stream if this is a failing value, otherwise an empty list.
    • iterator

      public Iterator<E> iterator()
      Returns an iterator for this projection. This method exists to permit the use in a for-each loop.
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      A iterator for this projection.