view flys-artifacts/src/main/java/de/intevation/flys/artifacts/AbstractStaticStateArtifact.java @ 4047:3dc26ec2558d

Removed dead code
author Sascha L. Teichmann <teichmann@intevation.de>
date Sat, 06 Oct 2012 11:08:24 +0200
parents 4e1b3b4ef132
children 44d27b8bb0bc 1755a1bfe5ce
line wrap: on
line source
package de.intevation.flys.artifacts;

import java.util.ArrayList;
import java.util.List;

import de.intevation.artifactdatabase.state.State;

/**
 * A abstract baseclass for Artifacts which are using only one static state.
 *
 * This class is intended to be used without the config/stateengine to generate
 * the static state.
 *
 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
 */
public abstract class AbstractStaticStateArtifact extends StaticFLYSArtifact {

    private transient State staticstate;

    /**
     * Get a list containing the one and only State.
     * @param  context ignored.
     * @return list with one and only state.
     */
    @Override
    protected List<State> getStates(Object context) {
        ArrayList<State> states = new ArrayList<State>();
        states.add(getStaticState());
        return states;
    }


    /**
     * Get the "current" state.
     * @param cc ignored.
     * @return always the set static state.
     */
    @Override
    public State getCurrentState(Object cc) {
        return getStaticState();
    }

    /**
     * A child class must override this method to set its static state
     */
    protected abstract void initStaticState();

    protected void setStaticState(State state) {
        this.staticstate = state;
    }

    protected State getStaticState() {
        if (staticstate == null) {
            initStaticState();
        }
        return staticstate;
    }

    /**
     * Get the state.
     * @param context ignored.
     * @param stateID ignored.
     * @return the state.
     */
    @Override
    protected State getState(Object context, String stateID) {
        return getStaticState();
    }
}

http://dive4elements.wald.intevation.org