Crossfire JXClient, Trunk
Location.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.map;
24 
25 import org.jetbrains.annotations.NotNull;
26 import org.jetbrains.annotations.Nullable;
27 
32 public class Location {
33 
37  private final int x;
38 
42  private final int y;
43 
47  private final int layer;
48 
55  public Location(final int x, final int y, final int layer) {
56  this.x = x;
57  this.y = y;
58  this.layer = layer;
59  }
60 
65  public int getX() {
66  return x;
67  }
68 
73  public int getY() {
74  return y;
75  }
76 
81  public int getLayer() {
82  return layer;
83  }
84 
85  @Override
86  public boolean equals(@Nullable final Object obj) {
87  if (obj == null) {
88  return false;
89  }
90  if (obj.getClass() != Location.class) {
91  return false;
92  }
93  final Location loc = (Location)obj;
94  return loc.x == x && loc.y == y && loc.layer == layer;
95  }
96 
97  @Override
98  public int hashCode() {
99  return x^y*0x1000^layer*0x1000000;
100  }
101 
102  @NotNull
103  @Override
104  public String toString() {
105  return x+"/"+y+"/"+layer;
106  }
107 
108 }
com.realtime.crossfire.jxclient.map.Location.equals
boolean equals(@Nullable final Object obj)
Definition: Location.java:86
com.realtime.crossfire.jxclient.map.Location.getY
int getY()
Definition: Location.java:73
com.realtime.crossfire.jxclient.map.Location.x
final int x
Definition: Location.java:37
com.realtime.crossfire.jxclient.map.Location
Definition: Location.java:32
com.realtime.crossfire.jxclient.map.Location.getX
int getX()
Definition: Location.java:65
com.realtime.crossfire.jxclient.map.Location.layer
final int layer
Definition: Location.java:47
com.realtime.crossfire.jxclient.map.Location.Location
Location(final int x, final int y, final int layer)
Definition: Location.java:55
com.realtime.crossfire.jxclient.map.Location.getLayer
int getLayer()
Definition: Location.java:81
com.realtime.crossfire.jxclient.map.Location.y
final int y
Definition: Location.java:42
com.realtime.crossfire.jxclient.map.Location.toString
String toString()
Definition: Location.java:104
com.realtime.crossfire.jxclient.map.Location.hashCode
int hashCode()
Definition: Location.java:98