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

astra.statement.TRStart Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
package astra.statement;

import astra.core.Intention;
import astra.formula.Predicate;
import astra.reasoner.util.ContextEvaluateVisitor;

public class TRStart extends AbstractStatement {
	Predicate function;
	
	public TRStart(String clazz, int[] data, Predicate function) {
		setLocation(clazz, data[0], data[1], data[2], data[3]);
		this.function = function;
	}

	@Override
	public StatementHandler getStatementHandler() {
		return new AbstractStatementHandler() {

			@Override
			public boolean execute(Intention context) {
				ContextEvaluateVisitor visitor = new ContextEvaluateVisitor(context); 
				if (!context.startFunction((Predicate) function.accept(visitor))) {
					context.failed("A TR Function is already Active");
					return true;
				}
				return false;
			}

			@Override
			public boolean onFail(Intention context) {
				return false;
			}

			@Override
			public Statement statement() {
				return TRStart.this;
			}
		};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy