| package org.maltparser.parser.transition;
|
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| public class Transition implements Comparable<Transition> {
|
| |
| |
|
|
| private final int code;
|
| |
| |
|
|
| private final String symbol;
|
| |
| |
|
|
| private final boolean labeled;
|
| private final int cachedHash;
|
| |
| |
| |
| |
| |
| |
|
|
| public Transition(int code, String symbol, boolean labeled) {
|
| this.code = code;
|
| this.symbol = symbol;
|
| this.labeled = labeled;
|
| final int prime = 31;
|
| int result = prime + code;
|
| result = prime * result + (labeled ? 1231 : 1237);
|
| this.cachedHash = prime * result + ((symbol == null) ? 0 : symbol.hashCode());
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public int getCode() {
|
| return code;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public String getSymbol() {
|
| return symbol;
|
| }
|
|
|
| |
| |
| |
| |
|
|
| public boolean isLabeled() {
|
| return labeled;
|
| }
|
|
|
|
|
| public int compareTo(Transition that) {
|
| final int BEFORE = -1;
|
| final int EQUAL = 0;
|
| final int AFTER = 1;
|
| if (this.code < that.code) return BEFORE;
|
| if (this.code > that.code) return AFTER;
|
| return EQUAL;
|
| }
|
|
|
| @Override
|
| public int hashCode() {
|
| return cachedHash;
|
| }
|
|
|
| @Override
|
| public boolean equals(Object obj) {
|
| if (this == obj)
|
| return true;
|
| if (obj == null)
|
| return false;
|
| if (getClass() != obj.getClass())
|
| return false;
|
| Transition other = (Transition) obj;
|
| if (code != other.code)
|
| return false;
|
| if (labeled != other.labeled)
|
| return false;
|
| if (symbol == null) {
|
| if (other.symbol != null)
|
| return false;
|
| } else if (!symbol.equals(other.symbol))
|
| return false;
|
| return true;
|
| }
|
|
|
| |
| |
|
|
| public String toString() {
|
| return symbol + " [" + code +"] " + labeled;
|
| }
|
| }
|
|
|