Class Either.AbstractProjection<A,​B>

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean contains​(A elem)
      Tests whether the option contains a given value as an element.
      Either<L,​R> either()
      The either value underlying this projection.
      boolean exists​(java.util.function.Predicate<? super A> f)
      Whether this is is defined and applying the predicate to the contained value returns true.
      boolean forall​(java.util.function.Predicate<? super A> f)
      Returns true if empty or the result of the application of the given function to the value.
      void foreach​(Effect<? super A> f)
      Deprecated.
      void forEach​(java.util.function.Consumer<? super A> f)  
      A getOr​(java.util.function.Supplier<? extends A> a)
      Get the value if defined or call the supplier and return its value if not.
      A getOrElse​(java.util.function.Supplier<? extends A> a)
      Deprecated.
      <X extends A>
      A
      getOrElse​(X x)
      Get the value if defined, otherwise returns other.
      A getOrError​(java.util.function.Supplier<java.lang.String> err)
      Get the value or throws an error with the supplied message if not defined.
      A getOrNull()
      Get the value if defined or null if not.
      <X extends java.lang.Throwable>
      A
      getOrThrow​(java.util.function.Supplier<X> ifUndefined)
      Get the value or throws the supplied throwable if not defined.
      boolean isEmpty()
      If the type does not contain a value return true.
      java.util.Iterator<A> iterator()
      Return an iterator for this type.
      Option<A> toOption()
      Returns this projection's value in Some if it exists, otherwise None.
      java.util.Optional<A> toOptional()
      Returns this projection's value in Optional.of(T) if it exists, otherwise Optional.empty().
      java.util.stream.Stream<A> toStream()
      Returns this projection's value in Stream.of(T) if it exists, otherwise Stream.empty().
      • 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

        spliterator
    • Constructor Detail

      • AbstractProjection

        AbstractProjection()
    • Method Detail

      • iterator

        public final java.util.Iterator<A> iterator()
        Description copied from interface: Maybe
        Return an iterator for this type. In most cases this takes the form of an iterator returning zero or one values.
        Specified by:
        iterator in interface java.lang.Iterable<A>
        Specified by:
        iterator in interface Maybe<A>
        Returns:
        an iterator over the contained value if defined, or an empty one otherwise.
      • either

        public final Either<L,​R> either()
        Description copied from interface: Either.Projection
        The either value underlying this projection.
        Specified by:
        either in interface Either.Projection<A,​B,​L,​R>
        Returns:
        The either value underlying this projection.
      • isEmpty

        public final boolean isEmpty()
        Description copied from interface: Maybe
        If the type does not contain a value return true.
        Specified by:
        isEmpty in interface Maybe<A>
        Returns:
        true if this does not hold a value, false otherwise.
      • toOption

        public final Option<A> toOption()
        Description copied from interface: Either.Projection
        Returns this projection's value in Some if it exists, otherwise None.
        Specified by:
        toOption in interface Either.Projection<A,​B,​L,​R>
        Returns:
        This projection's value in Some if it exists, otherwise None.
      • toOptional

        public final java.util.Optional<A> toOptional()
        Description copied from interface: Either.Projection
        Returns this projection's value in Optional.of(T) if it exists, otherwise Optional.empty().
        Specified by:
        toOptional in interface Either.Projection<A,​B,​L,​R>
        Returns:
        This projection's value in of if it exists, otherwise empty.
      • toStream

        public final java.util.stream.Stream<A> toStream()
        Description copied from interface: Either.Projection
        Returns this projection's value in Stream.of(T) if it exists, otherwise Stream.empty().
        Specified by:
        toStream in interface Either.Projection<A,​B,​L,​R>
        Returns:
        This projection's value in of if it exists, otherwise empty.
      • exists

        public final boolean exists​(java.util.function.Predicate<? super A> f)
        Description copied from interface: Maybe
        Whether this is is defined and applying the predicate to the contained value returns true.
        Specified by:
        exists in interface Maybe<A>
        Parameters:
        f - the predicate to test, must not be null
        Returns:
        true if defined and the predicate returns true for the contained value, false otherwise.
      • getOrNull

        public final A getOrNull()
        Description copied from interface: Maybe
        Get the value if defined or null if not.

        Although the use of null is discouraged, code written to use these must often interface with code that expects and returns nulls.

        Specified by:
        getOrNull in interface Maybe<A>
        Returns:
        the value or null if not defined
      • forall

        public final boolean forall​(java.util.function.Predicate<? super A> f)
        Description copied from interface: Maybe
        Returns true if empty or the result of the application of the given function to the value.
        Specified by:
        forall in interface Maybe<A>
        Parameters:
        f - The predicate function to test on the contained value, must not be null
        Returns:
        true if no value or returns the result of the application of the given function to the value.
      • contains

        public boolean contains​(A elem)
        Description copied from interface: Maybe
        Tests whether the option contains a given value as an element.
        Specified by:
        contains in interface Maybe<A>
        Parameters:
        elem - the element to test
        Returns:
        true if the option has an element that is equal to elem, false otherwise
      • getOrError

        public final A getOrError​(java.util.function.Supplier<java.lang.String> err)
        Description copied from interface: Maybe
        Get the value or throws an error with the supplied message if not defined.

        Used when absolutely sure this is defined.

        Specified by:
        getOrError in interface Maybe<A>
        Parameters:
        err - the message for the error.
        Returns:
        the contained value.
      • getOrThrow

        public <X extends java.lang.Throwable> A getOrThrow​(java.util.function.Supplier<X> ifUndefined)
                                                     throws X extends java.lang.Throwable
        Description copied from interface: Maybe
        Get the value or throws the supplied throwable if not defined.

        Used when absolutely sure this is defined.

        Specified by:
        getOrThrow in interface Maybe<A>
        Type Parameters:
        X - exception type
        Parameters:
        ifUndefined - the supplier of the throwable.
        Returns:
        the contained value.
        Throws:
        X - the throwable the supplier creates if there is no value.
        X extends java.lang.Throwable
      • getOr

        public final A getOr​(java.util.function.Supplier<? extends A> a)
        Description copied from interface: Maybe
        Get the value if defined or call the supplier and return its value if not. Replaces Maybe.getOrElse(Supplier). Get the value if defined or call the supplier and return its value if not.
        Specified by:
        getOr in interface Maybe<A>
        Parameters:
        a - called if this is empty
        Returns:
        the wrapped value or the value from the Supplier
      • getOrElse

        @Deprecated
        public final A getOrElse​(java.util.function.Supplier<? extends A> a)
        Deprecated.
        Description copied from interface: Maybe
        Get the value if defined or call the supplier and return its value if not.
        Specified by:
        getOrElse in interface Maybe<A>
        Parameters:
        a - called if this is empty
        Returns:
        the wrapped value or the value from the Supplier
      • getOrElse

        public final <X extends AA getOrElse​(X x)
        Description copied from interface: Maybe
        Get the value if defined, otherwise returns other.
        Specified by:
        getOrElse in interface Maybe<A>
        Type Parameters:
        X - default value type
        Parameters:
        x - value to return if this is empty
        Returns:
        wrapped value if this is defined, otherwise returns other
      • foreach

        @Deprecated
        public final void foreach​(Effect<? super A> f)
        Deprecated.
        Description copied from interface: Effect.Applicant
        Perform the given side-effect for each contained element.
        Specified by:
        foreach in interface Effect.Applicant<A>
        Parameters:
        f - the input to use for performing the effect.
      • forEach

        public final void forEach​(java.util.function.Consumer<? super A> f)
        Specified by:
        forEach in interface java.lang.Iterable<A>