Package 

Class EOr


  • 
    public class EOr<A extends Object>
    
                        
    A container that can either be a Failure containing an E or Success containing a value
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class Companion
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final E error
      private final A value
    • Constructor Summary

      Constructors 
      Constructor Description
      EOr(E error, A value) Base constructor providing both E and value
    • Method Summary

      Modifier and Type Method Description
      final Boolean hasError() Whether or not this contains an E
      final Boolean hasValue() Whether or not this contains a value
      final <B extends Any> EOr<B> map(Function1<A, B> f) Converts value in this, if it exists, using given mapping function to make a new EOr
      final <B extends Any> EOr<B> flatMap(Function1<A, EOr<B>> f) Computes a new EOr using value in this, if it exists, with given flat mapping function
      final EOr<A> mapError(Function1<E, E> f) Converts E in this, if it exists, using given mapping function to make a new EOr
      final <B extends Any> B fold(Function1<E, B> ifFailure, Function1<A, B> ifSuccess) Folds this into a single value, handling both E and value conversions with given functions
      final <B extends Any> EOr<B> andThen(Function0<EOr<B>> next) Provides a next EOr if this one has a value, ignoring the value
      final <U extends Any> EOr<A> onError(Function1<E, U> f) Performs a side-effect using error in this, if it exists
      final <U extends Any> EOr<A> onValue(Function1<A, U> f) Performs a side-effect using value in this, if it exists
      final <U extends Any> EOr<A> forEach(Function1<A, U> f) Alias of onValue
      final EOr<A> filter(Function1<A, Boolean> condition, Function1<A, E> filteredError) Filters this EOr by value in it, if it exists, using given function
      E getError()
      A getValue()
      • Methods inherited from class e.kotlin.EOr

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EOr

        EOr(E error, A value)
        Base constructor providing both E and value
        Parameters:
        error - E in this EOr
        value - Value in this EOr
    • Method Detail

      • map

         final <B extends Any> EOr<B> map(Function1<A, B> f)
        Converts value in this, if it exists, using given mapping function to make a new EOr
        Parameters:
        f - Mapping function
      • flatMap

         final <B extends Any> EOr<B> flatMap(Function1<A, EOr<B>> f)
        Computes a new EOr using value in this, if it exists, with given flat mapping function
        Parameters:
        f - Flat mapping function
      • mapError

         final EOr<A> mapError(Function1<E, E> f)
        Converts E in this, if it exists, using given mapping function to make a new EOr
        Parameters:
        f - E mapping function
      • fold

         final <B extends Any> B fold(Function1<E, B> ifFailure, Function1<A, B> ifSuccess)
        Folds this into a single value, handling both E and value conversions with given functions
        Parameters:
        ifFailure - Conversion function for E
        ifSuccess - Conversion function for value
      • andThen

         final <B extends Any> EOr<B> andThen(Function0<EOr<B>> next)
        Provides a next EOr if this one has a value, ignoring the value
        Parameters:
        next - Next EOr in case this one has a value
      • onError

         final <U extends Any> EOr<A> onError(Function1<E, U> f)
        Performs a side-effect using error in this, if it exists
        Parameters:
        f - Side-effecting function
      • onValue

         final <U extends Any> EOr<A> onValue(Function1<A, U> f)
        Performs a side-effect using value in this, if it exists
        Parameters:
        f - Side-effecting function
      • filter

         final EOr<A> filter(Function1<A, Boolean> condition, Function1<A, E> filteredError)
        Filters this EOr by value in it, if it exists, using given function
        Parameters:
        condition - Filtering function
        filteredError - E conversion function