org.gcube.smartgears.lifecycle
Class DefaultLifecycle<S extends State<S>>

java.lang.Object
  extended by 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>


Constructor Summary
DefaultLifecycle(org.gcube.common.events.Hub hub, String name, S startState)
           
 
Method Summary
 void moveTo(S next)
          Transition this lifecycle to a given state.
 S previous()
          Returns the state from which this lifecycle transitioned to its current state.
 S 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 Detail

DefaultLifecycle

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

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


Copyright © 2013. All Rights Reserved.