Interface Stopper<M extends com.jnape.palatable.lambda.monad.Monad<?,​M>>

  • Type Parameters:
    M - the monad type

    public interface Stopper<M extends com.jnape.palatable.lambda.monad.Monad<?,​M>>
    Starter and Stopper form a mechanism for controlling an application component that requires set up and tear down. The App class provides the start method which properly invokes this functionality for components whose lifecycle runs matches the lifecycle of the application. However, it is also possible to use Starter and Stopper at any time in an application's life to control the lifecycle of a component, for example to control one that is request- scoped.
    See Also:
    Starter
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Stopper<M> andThen​(Stopper<M> next)
      Creates a new Stopper that will stop this and then stop next.
      default <N extends com.jnape.palatable.lambda.monad.Monad<?,​N>>
      Stopper<N>
      mapStopper​(com.jnape.palatable.winterbourne.NaturalTransformation<M,​N> trans)
      Transforms the Monad of the Stopper through the application of a NaturalTransformation.
      <MU extends com.jnape.palatable.lambda.monad.Monad<com.jnape.palatable.lambda.adt.Unit,​M>>
      MU
      stop()
      Stops an application component, returning a Unit in a monadic context.
      static <M extends com.jnape.palatable.lambda.monad.Monad<?,​M>>
      Stopper<M>
      stopper​(com.jnape.palatable.lambda.functions.Fn0<? extends com.jnape.palatable.lambda.monad.Monad<com.jnape.palatable.lambda.adt.Unit,​M>> stopper)
      A convenience method for creating a Stopper from a lambda expression.
    • Method Detail

      • stop

        <MU extends com.jnape.palatable.lambda.monad.Monad<com.jnape.palatable.lambda.adt.Unit,​M>> MU stop()
        Stops an application component, returning a Unit in a monadic context. It is expected that this method will be invoked, and the monadic effect of the returned value run at the appropriate time. Failure to do so should be considered a resource leak.
        Type Parameters:
        MU - the Unit wrapped in the monad type
        Returns:
        a Unit in a monadic context
      • andThen

        default Stopper<M> andThen​(Stopper<M> next)
        Creates a new Stopper that will stop this and then stop next. It should not normally be necessary for an application to invoke this method. The effect of nesting the lifecycles of two application components together is accomplished by calling the andThen method of Starter
        Parameters:
        next - a Stopper for another application component
        Returns:
        A Stopper that combines two others
      • mapStopper

        default <N extends com.jnape.palatable.lambda.monad.Monad<?,​N>> Stopper<N> mapStopper​(com.jnape.palatable.winterbourne.NaturalTransformation<M,​N> trans)
        Transforms the Monad of the Stopper through the application of a NaturalTransformation.
        Type Parameters:
        N - the new Monad type
        Parameters:
        trans - the NaturalTransformation to apply
        Returns:
        A Stopper with parametric type N
      • stopper

        static <M extends com.jnape.palatable.lambda.monad.Monad<?,​M>> Stopper<M> stopper​(com.jnape.palatable.lambda.functions.Fn0<? extends com.jnape.palatable.lambda.monad.Monad<com.jnape.palatable.lambda.adt.Unit,​M>> stopper)
        A convenience method for creating a Stopper from a lambda expression.
        Type Parameters:
        M - the Monad type
        Parameters:
        stopper - a Fn0 that implements stop
        Returns:
        A Stopper