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

org.coode.oppl.queryplanner.AbstractQueryPlannerItem Maven / Gradle / Ivy

package org.coode.oppl.queryplanner;

import static org.coode.oppl.utils.ArgCheck.checkNotNull;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.coode.oppl.ConstraintSystem;
import org.coode.oppl.Variable;
import org.coode.oppl.bindingtree.Assignment;
import org.coode.oppl.bindingtree.BindingNode;
import org.semanticweb.owlapi.model.OWLAxiom;

/** @author Luigi Iannone */
public abstract class AbstractQueryPlannerItem implements QueryPlannerItem {
    private final ConstraintSystem constraintSystem;

    /** @param constraintSystem
     *            constraintSystem */
    public AbstractQueryPlannerItem(ConstraintSystem constraintSystem) {
        this.constraintSystem = checkNotNull(constraintSystem, "constraintSystem");
    }

    protected Set merge(BindingNode leaf,
            Collection newLeaves) {
        Set toReturn = new HashSet();
        for (BindingNode bindingNode : newLeaves) {
            Set newAssignment = new HashSet(leaf.getAssignments());
            newAssignment.addAll(bindingNode.getAssignments());
            Set> newUnassigendVariables = new HashSet>(
                    leaf.getUnassignedVariables());
            newUnassigendVariables.addAll(bindingNode.getUnassignedVariables());
            toReturn.add(new BindingNode(newAssignment, newUnassigendVariables));
        }
        return toReturn;
    }

    /** @return the constraintSystem */
    public ConstraintSystem getConstraintSystem() {
        return constraintSystem;
    }

    protected boolean isVariableAxiom(OWLAxiom axiom) {
        return !getConstraintSystem().getAxiomVariables(axiom).isEmpty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy