org.xins.server.EngineState Maven / Gradle / Ivy
/*
* $Id: EngineState.java,v 1.15 2010/09/29 17:21:48 agoubard Exp $
*
* See the COPYRIGHT file for redistribution and use restrictions.
*/
package org.xins.server;
import org.xins.common.MandatoryArgumentChecker;
/**
* State of an Engine
.
*
* @version $Revision: 1.15 $ $Date: 2010/09/29 17:21:48 $
* @author Ernst de Haan
*/
final class EngineState {
static final Type INTERMEDIATE_STATE = new Type();
static final Type USABLE_STATE = new Type();
static final Type ERROR_STATE = new Type();
/**
* The INITIAL state.
*/
static final EngineState INITIAL =
new EngineState("INITIAL", INTERMEDIATE_STATE);
/**
* The BOOTSTRAPPING_FRAMEWORK state.
*/
static final EngineState BOOTSTRAPPING_FRAMEWORK =
new EngineState("BOOTSTRAPPING_FRAMEWORK", INTERMEDIATE_STATE);
/**
* The FRAMEWORK_BOOTSTRAP_FAILED state.
*/
static final EngineState FRAMEWORK_BOOTSTRAP_FAILED =
new EngineState("FRAMEWORK_BOOTSTRAP_FAILED", ERROR_STATE);
/**
* The CONSTRUCTING_API state.
*/
static final EngineState CONSTRUCTING_API =
new EngineState("CONSTRUCTING_API", INTERMEDIATE_STATE);
/**
* The API_CONSTRUCTION_FAILED state.
*/
static final EngineState API_CONSTRUCTION_FAILED =
new EngineState("API_CONSTRUCTION_FAILED", ERROR_STATE);
/**
* The BOOTSTRAPPING_API state.
*/
static final EngineState BOOTSTRAPPING_API =
new EngineState("BOOTSTRAPPING_API", INTERMEDIATE_STATE);
/**
* The API_BOOTSTRAP_FAILED state.
*/
static final EngineState API_BOOTSTRAP_FAILED =
new EngineState("API_BOOTSTRAP_FAILED", ERROR_STATE);
/**
* The INITIALIZING_API state.
*/
static final EngineState INITIALIZING_API =
new EngineState("INITIALIZING_API", INTERMEDIATE_STATE);
/**
* The API_INITIALIZATION_FAILED state.
*/
static final EngineState API_INITIALIZATION_FAILED =
new EngineState("API_INITIALIZATION_FAILED", ERROR_STATE);
/**
* The READY state.
*/
static final EngineState READY =
new EngineState("READY", USABLE_STATE);
/**
* The DISPOSING state.
*/
static final EngineState DISPOSING =
new EngineState("DISPOSING", INTERMEDIATE_STATE);
/**
* The DISPOSED state.
*/
static final EngineState DISPOSED
= new EngineState("DISPOSED", INTERMEDIATE_STATE);
/**
* The name of this state. Cannot be null
.
*/
private final String _name;
/**
* The type of this state. Never null
.
*/
private final Type _type;
/**
* Constructs a new EngineState
object.
*
* @param name
* the name of this state, cannot be null
.
*
* @param type
* the type of this state, cannot be null
.
*
* @throws IllegalArgumentException
* if name == null || type == null
.
*/
EngineState(String name, Type type)
throws IllegalArgumentException {
// Check preconditions
MandatoryArgumentChecker.check("name", name, "type", type);
// Initialize fields
_name = name;
_type = type;
}
/**
* Returns the name of this state.
*
* @return
* the name of this state, cannot be null
.
*/
public String getName() {
return _name;
}
/**
* Checks if this state is an error state.
*
* @return
* true
if this is an error state, false
* otherwise.
*/
public boolean isError() {
return _type == ERROR_STATE;
}
/**
* Checks if this state allows function invocations.
*
* @return
* true
if this state allows function invocations,
* false
otherwise.
*/
public boolean allowsInvocations() {
return _type == USABLE_STATE;
}
/**
* Returns a textual representation of this object.
*
* @return
* the name of this state, never null
.
*/
public String toString() {
return _name;
}
/**
* Categorization of an engine state.
*
* @version $Revision: 1.15 $ $Date: 2010/09/29 17:21:48 $
* @author Ernst de Haan
*/
static class Type {
/**
* Constructs a new instance.
*/
private Type() {
// empty
}
}
}