001//////////////////////////////////////////////////////////////////////////////// 002// checkstyle: Checks Java source code for adherence to a set of rules. 003// Copyright (C) 2001-2014 Oliver Burn 004// 005// This library is free software; you can redistribute it and/or 006// modify it under the terms of the GNU Lesser General Public 007// License as published by the Free Software Foundation; either 008// version 2.1 of the License, or (at your option) any later version. 009// 010// This library is distributed in the hope that it will be useful, 011// but WITHOUT ANY WARRANTY; without even the implied warranty of 012// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013// Lesser General Public License for more details. 014// 015// You should have received a copy of the GNU Lesser General Public 016// License along with this library; if not, write to the Free Software 017// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 018//////////////////////////////////////////////////////////////////////////////// 019package com.puppycrawl.tools.checkstyle.api; 020 021/** 022 * Immutable line and column numbers. 023 * 024 * @author Martin von Gagern 025 */ 026public class LineColumn implements Comparable<LineColumn> 027{ 028 029 /** The one-based line number */ 030 private final int mLine; 031 032 /** The zero-based column number */ 033 private final int mCol; 034 035 /** 036 * Constructs a new pair of line and column numbers. 037 * @param aLine the one-based line number 038 * @param aCol the zero-based column number 039 */ 040 public LineColumn(int aLine, int aCol) 041 { 042 mLine = aLine; 043 mCol = aCol; 044 } 045 046 /** @return the one-based line number */ 047 public int getLine() 048 { 049 return mLine; 050 } 051 052 /** @return the zero-based column number */ 053 public int getColumn() 054 { 055 return mCol; 056 } 057 058 /** {@inheritDoc} */ 059 public int compareTo(LineColumn aLineColumn) 060 { 061 return (this.getLine() != aLineColumn.getLine()) 062 ? this.getLine() - aLineColumn.getLine() 063 : this.getColumn() - aLineColumn.getColumn(); 064 } 065}