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

fr.boreal.model.formula.impl.FOConjunctionFactBaseWrapper Maven / Gradle / Ivy

The newest version!
package fr.boreal.model.formula.impl;

import fr.boreal.model.formula.api.FOFormula;
import fr.boreal.model.formula.api.FOFormulaConjunction;
import fr.boreal.model.kb.api.FactBase;
import fr.boreal.model.logicalElements.api.*;

import java.util.*;
import java.util.stream.Collectors;

/**
 * Class that allows to wrap a fact base into a FOConjunction
 *
 * @author Guillaume Pérution-Kihli
 */
public class FOConjunctionFactBaseWrapper implements FOFormulaConjunction {
    final FactBase factBase;

    public FOConjunctionFactBaseWrapper(FactBase factBase) {
        this.factBase = factBase;
    }

    @Override
    public Collection getSubElements() {
        return factBase.getAtomsInMemory();
    }

    @Override
    public Set asAtomSet() {
        return factBase.getAtomsInMemory();
    }

    @Override
    public Set getPredicates() {
        Set predicates = new HashSet<>();
        factBase.getPredicates().forEachRemaining(predicates::add);
        return predicates;
    }

    @Override
    public Set getVariables() {
        return factBase.getVariables().collect(Collectors.toSet());
    }

    @Override
    public Set getConstants() {
        return factBase.getConstants().collect(Collectors.toSet());
    }

    @Override
    public Set> getLiterals() {
        return factBase.getLiterals().collect(Collectors.toSet());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy