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

  • Type Parameters:
    M - the monad type

    public interface Starter<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:
    Stopper
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Starter<M> andThen​(Starter<M> next)
      Creates a new Starter will compose this and next so that this is started followed by next.
      default <N extends com.jnape.palatable.lambda.monad.Monad<?,​N>>
      Starter<N>
      mapStarter​(com.jnape.palatable.winterbourne.NaturalTransformation<M,​N> trans)
      Transforms the Monad of the Starter through the application of a NaturalTransformation.
      <MS extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,​M>>
      MS
      start()
      Starts an application component, returning a Stopper in a monadic context.
      static <M extends com.jnape.palatable.lambda.monad.Monad<?,​M>>
      Starter<M>
      starter​(com.jnape.palatable.lambda.functions.Fn0<? extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,​M>> starter)
      A convenience method for creating a Starter from a lambda expression.
    • Method Detail

      • start

        <MS extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,​M>> MS start()
        Starts an application component, returning a Stopper in a monadic context. The returned Stopper will stop the application component when invoked. It is expected that the returned Stopper will be invoked at the appropriate time, and failure to do so should be considered a resource leak.
        Type Parameters:
        MS - the Stopper wrapped in the monad type
        Returns:
        A stopper for the application component that has been started
      • andThen

        default Starter<M> andThen​(Starter<M> next)
        Creates a new Starter will compose this and next so that this is started followed by next. The Stopper that this composed Starter returns works in the reverse order, stopping the component managed by next first and then the component managed by this. This has the effect of nesting another application component's lifecycle within the boundaries of this one.
        Parameters:
        next - a Starter for another application component
        Returns:
        A Starter that combines two others
      • mapStarter

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

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