fr.boreal.io.dlgp.ParserResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integraal-io Show documentation
Show all versions of integraal-io Show documentation
Inputs and Outputs for integraal objects
The newest version!
package fr.boreal.io.dlgp;
import fr.boreal.model.formula.api.FOFormula;
import fr.boreal.model.logicalElements.api.Atom;
import fr.boreal.model.query.api.FOQuery;
import fr.boreal.model.rule.api.FORule;
import fr.boreal.views.datasource.AbstractViewWrapper;
import java.util.Collection;
import java.util.LinkedHashSet;
/**
* Result of the DLGP parsing
* @param atoms a
* @param rules r
* @param queries q
* @param views v
*/
public record ParserResult(
Collection atoms,
Collection rules,
Collection> queries,
Collection> views) {
/**
* Creates a union of two DlgpParserResult records.
*
* @param other The other DlgpParserResult to union with this one.
* @return A new DlgpParserResult representing the union of this and the other
* record.
*/
public ParserResult union(ParserResult other) {
// Create new collections for the union of atoms, rules, and queries
Collection unionAtoms = new LinkedHashSet<>(this.atoms);
Collection unionRules = new LinkedHashSet<>(this.rules);
Collection> unionQueries = new LinkedHashSet<>(this.queries);
Collection> unionViews = new LinkedHashSet<>(this.views);
// Add all elements from the other DlgpParserResult to the collections
unionAtoms.addAll(other.atoms);
unionRules.addAll(other.rules);
unionQueries.addAll(other.queries);
unionViews.addAll(other.views);
// Return a new DlgpParserResult with the union of the collections
return new ParserResult(unionAtoms, unionRules, unionQueries, unionViews);
}
}