1 module hunt.database.driver.postgresql.data.Line;
2 
3 import hunt.Double;
4 
5 /**
6  * Line data type in Postgres represented by the linear equation Ax + By + C = 0, where A and B are not both zero.
7  */
8 class Line {
9     private double a;
10     private double b;
11     private double c;
12 
13     this() {
14         this(0.0, 0.0, 0.0);
15     }
16 
17     this(double a, double b, double c) {
18         this.a = a;
19         this.b = b;
20         this.c = c;
21     }
22 
23     // this(JsonObject json) {
24     //     LineConverter.fromJson(json, this);
25     // }
26 
27     double getA() {
28         return a;
29     }
30 
31     void setA(double a) {
32         this.a = a;
33     }
34 
35     double getB() {
36         return b;
37     }
38 
39     void setB(double b) {
40         this.b = b;
41     }
42 
43     double getC() {
44         return c;
45     }
46 
47     void setC(double c) {
48         this.c = c;
49     }
50 
51     override
52     bool opEquals(Object o) {
53         if (this is o) return true;
54         Line that = cast(Line) o;
55         if(that is null) return false;
56 
57         if (a != that.a) return false;
58         if (b != that.b) return false;
59         if (c != that.c) return false;
60 
61         return true;
62     }
63 
64     override
65     size_t toHash() @trusted nothrow {
66         import hunt.Double;
67         ulong result;
68         ulong temp;
69         temp = Double.doubleToLongBits(a);
70         result = (temp ^ (temp >>> 32));
71         temp = Double.doubleToLongBits(b);
72         result = 31 * result + (temp ^ (temp >>> 32));
73         temp = Double.doubleToLongBits(c);
74         result = 31 * result + (temp ^ (temp >>> 32));
75         return cast(size_t)result;
76     }
77 
78     override
79     string toString() {
80         import std.conv;
81         return "Line{" ~ a.to!string() ~ "," ~ b.to!string() ~ "," ~ c.to!string() ~ "}";
82     }
83 
84     // JsonObject toJson() {
85     //     JsonObject json = new JsonObject();
86     //     LineConverter.toJson(this, json);
87     //     return json;
88     // }
89 }