NebulaGraph Java Client  release-3.8
GeographyWrapper.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.Geography;
9 import java.util.Objects;
10 
11 public class GeographyWrapper extends BaseDataObject {
12  private final Geography geography;
13 
14  public GeographyWrapper(Geography geography) {
15  this.geography = geography;
16  }
17 
18  public PolygonWrapper getPolygonWrapper() {
19  return new PolygonWrapper(geography.getPgVal());
20  }
21 
22  public LineStringWrapper getLineStringWrapper() {
23  return new LineStringWrapper(geography.getLsVal());
24  }
25 
26  public PointWrapper getPointWrapper() {
27  return new PointWrapper(geography.getPtVal());
28  }
29 
30  @Override
31  public boolean equals(Object o) {
32  if (this == o) {
33  return true;
34  }
35  if (o == null || getClass() != o.getClass()) {
36  return false;
37  }
39  switch (geography.getSetField()) {
40  case Geography.PTVAL:
41  return getPointWrapper().equals(that.getPointWrapper());
42  case Geography.LSVAL:
43  return getLineStringWrapper().equals(that.getLineStringWrapper());
44  case Geography.PGVAL:
45  return getPolygonWrapper().equals(that.getPolygonWrapper());
46  default:
47  return false;
48  }
49  }
50 
51  @Override
52  public String toString() {
53  switch (geography.getSetField()) {
54  case Geography.PTVAL:
55  return getPointWrapper().toString();
56  case Geography.LSVAL:
57  return getLineStringWrapper().toString();
58  case Geography.PGVAL:
59  return getPolygonWrapper().toString();
60  default:
61  return "";
62  }
63  }
64 
65  @Override
66  public int hashCode() {
67  return Objects.hash(geography);
68  }
69 }