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

rationals.Transition Maven / Gradle / Ivy

Go to download

HermiT is reasoner for ontologies written using the Web Ontology Language (OWL). Given an OWL file, HermiT can determine whether or not the ontology is consistent, identify subsumption relationships between classes, and much more. This is the maven build of HermiT and is designed for people who wish to use HermiT from within the OWL API. It is now versioned in the main HermiT version repository, although not officially supported by the HermiT developers. The version number of this package is a composite of the HermiT version and a value representing the OWLAPI release it is compatible with. Note that the group id for the upstream HermiT is com.hermit-reasoner, while this fork is released under net.sourceforge.owlapi. This fork exists to allow HermiT users to use newer OWLAPI versions than the ones supported by the original HermiT codebase. This package includes the Jautomata library (http://jautomata.sourceforge.net/), and builds with it directly. This library appears to be no longer under active development, and so a "fork" seems appropriate. No development is intended or anticipated on this code base.

The newest version!
package rationals;

/**
 * Defines a Transition (an edge from a state to a state) in an Automaton
 * 
 * This class defines the notion of transition of an automaton. a transition is
 * a triple (q , l , q') where q, q' are states and l
 * a label. States q and q' must belong to the same automaton
 * A and the transition may only be used with this automaton A
 * .
 * 
 * @author [email protected]
 * @version 1.0
 * @see Automaton
 */
public class Transition {

    private int hash = Integer.MIN_VALUE;

    private final State start;

    private Object label;

    private final State end;

    /**
     * Creates a new transition (q , l , q').
     * 
     * @param start
     *            the state q for this transition (q , l , q')
     *            .
     * @param label
     *            the label l
     * @param end
     *            the state q' for this transition
     *            (q , l , q').
     */
    public Transition(State start, Object label, State end) {
        this.start = start;
        this.label = label;
        this.end = end;
    }

    /**
     * Returns the starting state of this transition.
     * 
     * @return the starting state of this transition, that is the state
     *         q for this transition (q , l , q').
     */
    public State start() {
        return start;
    }

    /**
     * Returns the label this transition.
     * 
     * @return the label state of this transition, that is the object l
     *         for this transition (q , l , q').
     */
    public Object label() {
        return label;
    }

    /**
     * Returns the ending state of this transition.
     * 
     * @return the ending state of this transition, that is the state
     *         q' for this transition (q , l , q').
     */
    public State end() {
        return end;
    }

    /**
     * returns a textual representation of this transition.
     * 
     * @return a textual representation of this transition based
     */
    @Override
    public String toString() {
        if (label == null) {
            return "(" + start + " , 1 , " + end + ")";
        } else {
            return "(" + start + " , " + label + " , " + end + ")";
        }
    }

    /**
     * Determines if this transition is equal to the parameter.
     * 
     * @param o
     *            any object.
     * @return true iff this transition is equal to the parameter. That is if
     *         {@code o} is a transition which is composed same states and
     *         label (in the sense of method {@code equals}).
     */
    @Override
    public boolean equals(Object o) {
        if (o == null)
            return false;
        if (this == o) {
            return true;
        }
        if (o instanceof Transition) {
            Transition t = (Transition) o;
            if (label != t.label) {
                if (label == null || t.label == null)
                    return false;
                if (!t.label.equals(label))
                    return false;
            }
            return (start == t.start()) && (end == t.end());
        }
        return false;
    }

    @Override
    public int hashCode() {
        /* store computed value */
        if (hash != Integer.MIN_VALUE)
            return hash;
        int x, y, z;
        if (start == null)
            x = 0;
        else
            x = start.hashCode();
        if (end == null)
            y = 0;
        else
            y = end.hashCode();
        if (label == null)
            z = 0;
        else
            z = label.hashCode();
        int t = new java.awt.Point(x, y).hashCode();
        return hash = new java.awt.Point(t, z).hashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy