
fr.inria.edelweiss.kgdqp.core.BasicGraphPattern Maven / Gradle / Ivy
package fr.inria.edelweiss.kgdqp.core;
import fr.inria.edelweiss.kgram.api.core.Edge;
import java.util.ArrayList;
/**
* An helper class to handle connected basic graph patterns.
* @author Alban Gaignard, [email protected]
*/
public class BasicGraphPattern {
private ArrayList vars;
private ArrayList edges;
private boolean processed;
public BasicGraphPattern() {
vars = new ArrayList();
edges = new ArrayList();
processed = false;
}
public boolean isProcessed() {
return processed;
}
public void setProcessed(boolean processed) {
this.processed = processed;
}
public ArrayList getEdges() {
return edges;
}
public void setEdges(ArrayList edges) {
this.edges = edges;
}
public ArrayList getVars() {
return vars;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BasicGraphPattern other = (BasicGraphPattern) obj;
for (String oV : other.getVars()) {
if (!this.getVars().contains(oV)) {
return false;
}
}
for (Edge oE : other.getEdges()) {
if (!this.getEdges().contains(oE)) {
return false;
}
}
return true;
}
@Override
public int hashCode() {
int hash = 3;
hash = 23 * hash + (this.vars != null ? this.vars.hashCode() : 0);
hash = 23 * hash + (this.edges != null ? this.edges.hashCode() : 0);
return hash;
}
@Override
public String toString() {
String sVars = "[";
for (String s : vars) {
sVars += s + " ";
}
sVars += "]";
String res = "BasicGraphPattern{" + "vars=" + sVars + ", edges=\n";
for (Edge e : edges) {
res += "\t" + e.toString() + "\n";
}
res += "}";
return res;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy