Class DefaultLifecycle<S extends State<S>>

java.lang.Object
org.gcube.smartgears.lifecycle.DefaultLifecycle<S>
All Implemented Interfaces:
Lifecycle<S>
Direct Known Subclasses:
ApplicationLifecycle, ContainerLifecycle

public class DefaultLifecycle<S extends State<S>> extends Object implements Lifecycle<S>
Default implementation of Lifecycle
Author:
Luca Frosini (ISTI-CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultLifecycle(org.gcube.common.events.Hub hub, String name, S startState)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    moveTo(S next)
    Transition this lifecycle to a given state.
    Returns the state from which this lifecycle transitioned to its current state.
    Returns the current state of this lifecycle.
    boolean
    tryMoveTo(S next)
    Attempts to transition this lifecycle to a given state, but does not fail if the transition is illegal for this lifecycle.

    Methods inherited from class java.lang.Object

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

    • DefaultLifecycle

      public DefaultLifecycle(org.gcube.common.events.Hub hub, String name, S startState)
  • Method Details

    • state

      public S state()
      Description copied from interface: Lifecycle
      Returns the current state of this lifecycle.
      Specified by:
      state in interface Lifecycle<S extends State<S>>
      Returns:
      the current state.
    • moveTo

      public void moveTo(S next)
      Description copied from interface: Lifecycle
      Transition this lifecycle to a given state.
      Specified by:
      moveTo in interface Lifecycle<S extends State<S>>
      Parameters:
      next - the state
    • tryMoveTo

      public boolean tryMoveTo(S next)
      Description copied from interface: Lifecycle
      Attempts to transition this lifecycle to a given state, but does not fail if the transition is illegal for this lifecycle.
      Specified by:
      tryMoveTo in interface Lifecycle<S extends State<S>>
      Parameters:
      next - the state
      Returns:
      true if this lifecycle has transitioned to the given state
    • previous

      public S previous()
      Description copied from interface: Lifecycle
      Returns the state from which this lifecycle transitioned to its current state.
      Specified by:
      previous in interface Lifecycle<S extends State<S>>
      Returns:
      the previous state