![JAR search and dependency download from the Maven repository](/logo.png)
fr.lirmm.boreal.util.converter.AtomConverter Maven / Gradle / Ivy
package fr.lirmm.boreal.util.converter;
import java.util.List;
import java.util.stream.Collectors;
import fr.boreal.model.logicalElements.api.Atom;
import fr.boreal.model.logicalElements.api.Predicate;
import fr.boreal.model.logicalElements.api.Term;
import fr.boreal.model.logicalElements.impl.AtomImpl;
/**
* Converts Atom to and from Graal's Atom
*
* This is used for compatibility with Graal 1.3 version.
*
* @author Florent Tornil
*
*/
public class AtomConverter {
/**
* Converts the given Atom into a Graal Atom
* @param a the atom to convert
* @return the converted atom
*/
public static fr.lirmm.graphik.integraal.api.core.Atom convert(Atom a) {
fr.lirmm.graphik.integraal.api.core.Predicate p = PredicateConverter.convert(a.getPredicate());
List terms = List.of(a.getTerms()).stream().map(t -> TermConverter.convert(t)).collect(Collectors.toList());
return fr.lirmm.graphik.integraal.core.factory.DefaultAtomFactory.instance().create(p, terms);
}
/**
* Converts the given Atom into a Graal Atom
* @param a the atom to convert
* @return the converted atom
*/
public static fr.lirmm.graphik.graal.api.core.Atom convert2(Atom a) {
fr.lirmm.graphik.graal.api.core.Predicate p = PredicateConverter.convert2(a.getPredicate());
List terms = List.of(a.getTerms()).stream().map(t -> TermConverter.convert2(t)).collect(Collectors.toList());
return fr.lirmm.graphik.graal.core.factory.DefaultAtomFactory.instance().create(p, terms);
}
/**
* Converts the given Graal Atom into an Atom
* @param a the atom to convert
* @return the converted atom
*/
public static Atom reverse(fr.lirmm.graphik.integraal.api.core.Atom a) {
Predicate p = PredicateConverter.reverse(a.getPredicate());
List terms = a.getTerms().stream().map(t -> TermConverter.reverse(t)).collect(Collectors.toList());
return new AtomImpl(p, terms);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy