| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Position |
|
| 2.5;2.5 |
| 1 | /******************************************************************************* | |
| 2 | * Copyright (c) 2008-2010 Ketan Padegaonkar and others. | |
| 3 | * All rights reserved. This program and the accompanying materials | |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 | |
| 5 | * which accompanies this distribution, and is available at | |
| 6 | * http://www.eclipse.org/legal/epl-v10.html | |
| 7 | * | |
| 8 | * Contributors: | |
| 9 | * Ketan Padegaonkar - initial API and implementation | |
| 10 | *******************************************************************************/ | |
| 11 | package org.eclipse.swtbot.swt.finder.utils; | |
| 12 | ||
| 13 | /** | |
| 14 | * An object that represents a position in terms of line and column number. | |
| 15 | * | |
| 16 | * @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com> | |
| 17 | * @version $Id$ | |
| 18 | */ | |
| 19 | public class Position { | |
| 20 | ||
| 21 | /** the line number */ | |
| 22 | public final int line; | |
| 23 | /** the column number */ | |
| 24 | public final int column; | |
| 25 | ||
| 26 | /** | |
| 27 | * Create a position. | |
| 28 | * | |
| 29 | * @param line the line number. | |
| 30 | * @param column the column number. | |
| 31 | */ | |
| 32 | 18 | public Position(int line, int column) { |
| 33 | 18 | this.line = line; |
| 34 | 18 | this.column = column; |
| 35 | 18 | } |
| 36 | ||
| 37 | @Override | |
| 38 | public int hashCode() { | |
| 39 | final int prime = 31; | |
| 40 | 8 | int result = 1; |
| 41 | 8 | result = prime * result + column; |
| 42 | 8 | result = prime * result + line; |
| 43 | 8 | return result; |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | public boolean equals(Object obj) { | |
| 48 | 6 | if (this == obj) |
| 49 | 1 | return true; |
| 50 | 5 | if ((obj == null) || (getClass() != obj.getClass())) |
| 51 | 1 | return false; |
| 52 | 4 | Position other = (Position) obj; |
| 53 | 4 | return (column == other.column) && (line == other.line); |
| 54 | } | |
| 55 | ||
| 56 | @Override | |
| 57 | public String toString() { | |
| 58 | 0 | return "Position: (" + line + ", " + column + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 59 | } | |
| 60 | } |