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
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
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