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

de.uni.freiburg.iig.telematik.jagal.ts.serialize.TSSerializer Maven / Gradle / Ivy

package de.uni.freiburg.iig.telematik.jagal.ts.serialize;

import de.invation.code.toval.validate.ParameterException;
import de.invation.code.toval.validate.ParameterException.ErrorCode;
import de.invation.code.toval.validate.Validate;
import de.uni.freiburg.iig.telematik.jagal.ts.TSType;
import de.uni.freiburg.iig.telematik.jagal.ts.abstr.AbstractState;
import de.uni.freiburg.iig.telematik.jagal.ts.abstr.AbstractTransitionRelation;
import de.uni.freiburg.iig.telematik.jagal.ts.abstr.AbstractTransitionSystem;

public abstract class TSSerializer<	S extends AbstractState, 
								   	T extends AbstractTransitionRelation,
									O extends Object>{
	
	protected AbstractTransitionSystem transitionSystem = null;
	
	public TSSerializer(AbstractTransitionSystem ts) throws ParameterException{
		validateTransitionSystem(ts);
	}
	
	private void validateTransitionSystem(AbstractTransitionSystem ts) throws ParameterException{
		Validate.notNull(ts);
		Class requiredClassType = TSType.getClassType(acceptedNetType());
		if(!(requiredClassType.isAssignableFrom(ts.getClass()))){
			throw new ParameterException(ErrorCode.INCOMPATIBILITY, "The serializer requires nets of type \""+requiredClassType+"\"\n The given net is of type \""+ts.getClass()+"\"");
		}
		this.transitionSystem = ts;
	}
	
	public AbstractTransitionSystem getTransitionSystem(){
		return transitionSystem;
	}
	
	public abstract TSType acceptedNetType();
	
	public abstract String serialize() throws SerializationException;
			
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy