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

org.protege.owlapi.inference.orphan.Path Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy