001/*
002 * Copyright (C) 2009-2011 Mathias Doenitz
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.parboiled.support;
018
019/**
020 * Simple container class for a line/column position in the input text.
021 */
022public final class Position {
023    public final int line;
024    public final int column;
025
026    public Position(int line, int column) {
027        this.line = line;
028        this.column = column;
029    }
030
031    @Override
032    public boolean equals(Object o) {
033        if (this == o) return true;
034        if (!(o instanceof Position)) return false;
035        Position position = (Position) o;
036        return column == position.column && line == position.line;
037
038    }
039
040    @Override
041    public int hashCode() {
042        int result = line;
043        result = 31 * result + column;
044        return result;
045    }
046
047    @Override
048    public String toString() {
049        return "Position{" +
050                "line=" + line +
051                ", column=" + column +
052                '}';
053    }
054}