All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cz.wicketstuff.boss.flow.builder.xml.FlowBuilderCarter Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
/*
 * Et netera, http://boss.etnetera.cz - Copyright (C) 2012 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License (version 2.1) as published by the Free Software
 * Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU Lesser General Public License for more details:
 * http://www.gnu.org/licenses/lgpl-3.0.txt
 * 
 */
package cz.wicketstuff.boss.flow.builder.xml;

import java.util.Map;

import cz.wicketstuff.boss.flow.model.IFlowState;

/**
 * A carter to hold maps with state and transition holders.
 * 
 * @author Martin Strejc
 *
 */
public class FlowBuilderCarter {

	private Map stateIdsMap;
	private Map stateNamesMap;
	private Map transitionIdsMap;
	private Map transitionNamesMap;

	private IFlowState defaultInitialState;
	
	public FlowBuilderCarter() {
	}

	public FlowBuilderCarter(Map stateIdsMap,
			Map stateNamesMap,
			Map transitionIdsMap,
			Map transitionNamesMap) {
		this.stateIdsMap = stateIdsMap;
		this.stateNamesMap = stateNamesMap;
		this.transitionIdsMap = transitionIdsMap;
		this.transitionNamesMap = transitionNamesMap;
	}

	public Map getStateIdsMap() {
		return stateIdsMap;
	}

	public void setStateIdsMap(Map stateIdsMap) {
		this.stateIdsMap = stateIdsMap;
	}

	public Map getStateNamesMap() {
		return stateNamesMap;
	}

	public void setStateNamesMap(Map stateNamesMap) {
		this.stateNamesMap = stateNamesMap;
	}

	public Map getTransitionIdsMap() {
		return transitionIdsMap;
	}

	public void setTransitionIdsMap(Map transitionIdsMap) {
		this.transitionIdsMap = transitionIdsMap;
	}

	public Map getTransitionNamesMap() {
		return transitionNamesMap;
	}

	public void setTransitionNamesMap(
			Map transitionNamesMap) {
		this.transitionNamesMap = transitionNamesMap;
	}
	
	public TransitionCapsule findTransition(String name) throws IllegalArgumentException {
		if(name == null) {
			throw new IllegalArgumentException("Cannot find transition for id=null and name=null");
		}
		TransitionCapsule tc = null;
		tc = getTransitionNamesMap().get(name);
		return tc;
	}

	public StateCapsule findState(String name) throws IllegalArgumentException {
		if(name == null) {
			throw new IllegalArgumentException("Cannot find transition for id=null and name=null");
		}
		StateCapsule sc = null;
			sc = getStateNamesMap().get(name);
		return sc;
	}

	public IFlowState getDefaultInitialState() {
		return defaultInitialState;
	}

	public void setDefaultInitialState(IFlowState defaultInitialState) {
		this.defaultInitialState = defaultInitialState;
	}

	@Override
	protected void finalize() throws Throwable {
		if(stateIdsMap != null) {
			stateIdsMap.clear();
			stateIdsMap = null;			
		}
		if(stateNamesMap != null) {
			stateNamesMap.clear();
			stateNamesMap = null;
		}
		if(transitionIdsMap != null) {
			transitionIdsMap.clear();
			transitionIdsMap = null;
		}
		if(transitionNamesMap != null) {
			transitionNamesMap.clear();
			transitionNamesMap = null;
		}
		defaultInitialState = null;
		super.finalize();
	}
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy