org.protege.owlapi.inference.orphan.Path Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protege-owlapi-extensions Show documentation
Show all versions of protege-owlapi-extensions Show documentation
Extensions to the OWL API (http://owlapi.sourceforge.net/) for Protege
package org.protege.owlapi.inference.orphan;
import java.util.ArrayList;
import java.util.List;
public class Path {
private Path next;
private X object;
public Path(X x) {
this.object = x;
}
public Path(Path p, X x) {
next = p;
object = x;
}
public Path getNext() {
return next;
}
public X getObject() {
return object;
}
public boolean contains(X x) {
Path point = this;
do {
if (point.getObject().equals(x)) {
return true;
}
} while ((point = point.getNext()) != null);
return false;
}
public List getLoop(X x) {
List result = new ArrayList();
result.add(x);
Path point = this;
do {
if (point.getObject().equals(x)) {
break;
}
else {
result.add(point.getObject());
}
} while ((point = point.getNext()) != null);
return result;
}
public String toString() {
String objectVal = object == null ? "null" : object.toString();
if (next == null) {
return objectVal;
}
return objectVal + " -> " + next.toString();
}
}