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

astra.messaging.Utilities Maven / Gradle / Ivy

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

import astra.formula.Formula;
import astra.formula.Predicate;
import astra.reasoner.util.LogicVisitor;
import astra.term.Term;

public class Utilities {
	public static class PredicateState implements Formula {
		/**
		 * 
		 */
		private static final long serialVersionUID = -8065767049634724024L;
		public Term[] terms;
		public String predicate;
		
		public PredicateState(Predicate predicate) {
			this.predicate = predicate.predicate();
			terms = predicate.terms();
		}

		@Override
		public Object accept(LogicVisitor visitor) {
			return null;
		}

		@Override
		public boolean matches(Formula formula) {
			return false;
		}
	}

	public static PredicateState toPredicateState(Formula formula) {
		// Transform the state into one that can be sent...
		if (formula instanceof Predicate) {
			return new PredicateState((Predicate) formula);
		}
		System.out.println("[MigrationKit] Could not transform belief: " + formula);
		return null;
	}
	
	public static Formula fromPredicateState(PredicateState state) {
		return new Predicate(state.predicate, state.terms);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy