Package ideah.formatter

Source Code of ideah.formatter.MyLocation

package ideah.formatter;

import com.intellij.openapi.util.TextRange;
import ideah.tree.ILocation;

final class MyLocation implements ILocation {

    private final int offset;

    MyLocation(int offset) {
        this.offset = offset;
    }

    static MyRange create(MyLocation start, MyLocation end) {
        return new MyRange(new TextRange(start.offset, end.offset));
    }

    public int compareTo(ILocation o) {
        MyLocation that = (MyLocation) o;
        if (this.offset < that.offset) {
            return -1;
        } else if (this.offset > that.offset) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MyLocation) {
            MyLocation that = (MyLocation) obj;
            return this.offset == that.offset;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return offset;
    }

    @Override
    public String toString() {
        return String.valueOf(offset);
    }
}
TOP

Related Classes of ideah.formatter.MyLocation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.