package org.arakhne.neteditor.fsm.constructs ;

import java.io.IOException;
import java.util.Map;

public class FSMState extends AbstractFSMNode {

	private String enterAction = null;
	private String insideAction = null;
	private String exitAction = null;
	
	public FSMState() {
		super();
	}
	
	public String getEnterAction() {
		return this.enterAction;
	}

	public void setEnterAction(String action) {
		String na = (action==null || action.isEmpty()) ? null : action;
		if ((this.enterAction==null && na!=null)||
			(this.enterAction!=null && !this.enterAction.equals(na))) {
			String old = this.enterAction;
			this.enterAction = na;
			firePropertyChanged("enterAction", old, this.enterAction);
		}
	}
	
	public String getExitAction() {
		return this.exitAction;
	}

	public void setExitAction(String action) {
		String na = (action==null || action.isEmpty()) ? null : action;
		if ((this.exitAction==null && na!=null)||
			(this.exitAction!=null && !this.exitAction.equals(na))) {
			String old = this.exitAction;
			this.exitAction = na;
			firePropertyChanged("exitAction", old, this.exitAction);
		}
	}

	public String getAction() {
		return this.insideAction;
	}

	public void setAction(String action) {
		String na = (action==null || action.isEmpty()) ? null : action;
		if ((this.insideAction==null && na!=null)||
			(this.insideAction!=null && !this.insideAction.equals(na))) {
			String old = this.insideAction;
			this.insideAction = na;
			firePropertyChanged("insideAction", old, this.insideAction);
		}
	}

	@Override
	public Map<String, Object> getProperties() {
		Map<String,Object> properties = super.getProperties();
		properties.put("enterAction", this.enterAction);
		properties.put("insideAction", this.insideAction);
		properties.put("exitAction", this.exitAction);
		return properties;
	}
	
	@Override
	public void setProperties(Map<String, Object> properties)
			throws IOException {
		super.setProperties(properties);
		if (properties!=null) {
			setEnterAction(propGet(String.class, "enterAction", this.enterAction, properties));
			setExitAction(propGet(String.class, "exitAction", this.exitAction, properties));
			setAction(propGet(String.class, "insideAction", this.insideAction, properties));
		}
	}

}