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

de.uni.freiburg.iig.telematik.jagal.ts.exception.RelationNotFoundException Maven / Gradle / Ivy

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

import de.uni.freiburg.iig.telematik.jagal.graph.exception.EdgeNotFoundException;
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 class RelationNotFoundException extends TSException {

	private static final long serialVersionUID = -817667248805564124L;
	private static final String toStringFormat = "%s does not contain relation (%s -> %s)";
	
	private String sourceName = null;
	private String targetName = null;

	public , T extends AbstractTransitionRelation, O extends Object> 
	RelationNotFoundException(T edge, AbstractTransitionSystem ts){
		super(ts.getName());
		this.sourceName = edge.getSource().getName();
		this.targetName = edge.getTarget().getName();
	}
	
	public , T extends AbstractTransitionRelation, O extends Object> 
	RelationNotFoundException(String sourceName, String targetName, AbstractTransitionSystem ts){
		super(ts.getName());
		this.sourceName = sourceName;
		this.targetName = targetName;
	}
	
	public , T extends AbstractTransitionRelation, O extends Object> 
	RelationNotFoundException(EdgeNotFoundException graphException){
		super(graphException);
		this.sourceName = graphException.getSourceName();
		this.targetName = graphException.getTargetName();
	}
	
	public String getMessage(){
		return String.format(toStringFormat, getTSName(), getSourceName(), getTargetName());
	}
	
	public String getSourceName(){
		return sourceName;
	}

	public String getTargetName(){
		return targetName;
	}
	
}