Class Logged<A>

  • Type Parameters:
    A - the type of values

    public class Logged<A>
    extends Object
    Class representing Logged monad. Wraps a value and contains a log string.
    Author:
    Herbert Praehofer
    • Field Detail

      • value

        public final A value
        The wrapped value
      • log

        public final String log
        The log string
    • Constructor Detail

      • Logged

        private Logged​(A a,
                       String log)
        Constructor wrapping value and setting log string.
        Parameters:
        a - the wrapped value
        log - the log string
    • Method Detail

      • of

        public static <A> Logged<A> of​(A a,
                                       String log)
        Creates a Logged monad with a wrapped value.
        Type Parameters:
        A - the type of the value
        Parameters:
        a - the wrapped value
        log - the log message
        Returns:
        the monad with the wrapped value
      • flatMap

        public <B> Logged<B> flatMap​(Function<A,​Logged<B>> mapper)
        Monad operator mapping value and concatenating log strings.
        Type Parameters:
        B - the type of the wrapped result object.
        Parameters:
        mapper - the mapping function
        Returns:
        the wrapped result value