bjoern@3936: package de.intevation.flys.artifacts; bjoern@3936: bjoern@3936: import java.util.ArrayList; bjoern@3936: import java.util.List; bjoern@3936: bjoern@3936: import de.intevation.artifactdatabase.state.State; bjoern@3936: bjoern@4157: import de.intevation.flys.artifacts.states.StaticState; bjoern@4157: bjoern@3936: /** bjoern@3936: * A abstract baseclass for Artifacts which are using only one static state. bjoern@3936: * bjoern@3936: * This class is intended to be used without the config/stateengine to generate bjoern@3936: * the static state. bjoern@3936: * bjoern@3936: * @author Björn Ricks bjoern@3936: */ bjoern@3936: public abstract class AbstractStaticStateArtifact extends StaticFLYSArtifact { bjoern@3936: bjoern@4157: private transient StaticState staticstate; bjoern@3936: bjoern@3936: /** bjoern@3936: * Get a list containing the one and only State. bjoern@3936: * @param context ignored. bjoern@3936: * @return list with one and only state. bjoern@3936: */ bjoern@3936: @Override bjoern@3936: protected List getStates(Object context) { bjoern@3936: ArrayList states = new ArrayList(); bjoern@3936: states.add(getStaticState()); bjoern@3936: return states; bjoern@3936: } bjoern@3936: bjoern@3936: bjoern@3936: /** bjoern@3936: * Get the "current" state. bjoern@3936: * @param cc ignored. bjoern@3936: * @return always the set static state. bjoern@3936: */ bjoern@3936: @Override bjoern@3936: public State getCurrentState(Object cc) { bjoern@3936: return getStaticState(); bjoern@3936: } bjoern@3936: bjoern@3936: /** bjoern@3936: * A child class must override this method to set its static state bjoern@3936: */ bjoern@3936: protected abstract void initStaticState(); bjoern@3936: bjoern@4157: protected void setStaticState(StaticState state) { bjoern@3936: this.staticstate = state; bjoern@3936: } bjoern@3936: bjoern@4157: protected StaticState getStaticState() { bjoern@3936: if (staticstate == null) { bjoern@3936: initStaticState(); bjoern@3936: } bjoern@3936: return staticstate; bjoern@3936: } bjoern@3936: bjoern@3936: /** bjoern@3936: * Get the state. bjoern@3936: * @param context ignored. bjoern@3936: * @param stateID ignored. bjoern@3936: * @return the state. bjoern@3936: */ bjoern@3936: @Override bjoern@3936: protected State getState(Object context, String stateID) { bjoern@3936: return getStaticState(); bjoern@3936: } bjoern@3936: }