1 /*
2  * Copyright (C) 2018 Julien Viet
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 module hunt.database.driver.postgresql.data.Point;
18 
19 import std.conv;
20 
21 /**
22  * A Postgresql point.
23  */
24 class Point {
25 
26     private double x, y;
27 
28     this() {
29         this(0, 0);
30     }
31 
32     this(double x, double y) {
33         this.x = x;
34         this.y = y;
35     }
36 
37     // this(JsonObject json) {
38     //     PointConverter.fromJson(json, this);
39     // }
40 
41     double getX() {
42         return x;
43     }
44 
45     Point setX(double x) {
46         this.x = x;
47         return this;
48     }
49 
50     double getY() {
51         return y;
52     }
53 
54     Point setY(double y) {
55         this.y = y;
56         return this;
57     }
58 
59     override bool opEquals(Object obj) {
60         if (this is obj)
61             return true;
62         Point that = cast(Point) obj;
63         if (that is null)
64             return false;
65         return x == that.x && y == that.y;
66     }
67 
68     override string toString() {
69         return "this(" ~ x.to!string() ~ "," ~ y.to!string() ~ ")";
70     }
71 
72     // JsonObject toJson() {
73     //     JsonObject json = new JsonObject();
74     //     PointConverter.toJson(this, json);
75     //     return json;
76     // }
77 }