NebulaGraph Java Client  release-3.8
CoordinateWrapper.java
1 /* Copyright (c) 2021 vesoft inc. All rights reserved.
2  *
3  * This source code is licensed under Apache 2.0 License.
4  */
5 
6 package com.vesoft.nebula.client.graph.data;
7 
8 import com.vesoft.nebula.Coordinate;
9 import java.util.Arrays;
10 
11 public class CoordinateWrapper extends BaseDataObject {
12  private final Coordinate coordinate;
13 
14  public CoordinateWrapper(Coordinate coordinate) {
15  this.coordinate = coordinate;
16  }
17 
18  public double getX() {
19  return coordinate.getX();
20  }
21 
22  public double getY() {
23  return coordinate.getY();
24  }
25 
26  @Override
27  public boolean equals(Object o) {
28  if (this == o) {
29  return true;
30  }
31  if (o == null || getClass() != o.getClass()) {
32  return false;
33  }
35  return this.getX() == that.getX()
36  && this.getY() == that.getY();
37  }
38 
39  @Override
40  public String toString() {
41  StringBuilder sb = new StringBuilder();
42  sb.append("COORDINATE");
43  sb.append('(');
44  sb.append(coordinate.getX());
45  sb.append(' ');
46  sb.append(coordinate.getY());
47  sb.append(')');
48 
49  return sb.toString();
50  }
51 
52  @Override
53  public int hashCode() {
54  return Arrays.deepHashCode(new Object[] {this.getX(), this.getY()});
55  }
56 }