1 /*
2  * Copyright (C) 2019, HuntLabs
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.PostgreSQLNotification;
18 
19 // import io.vertx.codegen.annotations.DataObject;
20 // import io.vertx.core.json.JsonObject;
21 
22 
23 import hunt.database.base.Common;
24 
25 alias PgNotificationHandler = EventHandler!(PgNotification);
26 
27 /**
28  * A notification emited by Postgres.
29  */
30 class PgNotification {
31 
32     private int processId;
33     private string channel;
34     private string payload;
35 
36     this() {
37     }
38 
39     // this(JsonObject json) {
40     //     PgNotificationConverter.fromJson(json, this);
41     // }
42 
43     /**
44      * @return the notification process id
45      */
46     int getProcessId() {
47         return processId;
48     }
49 
50     /**
51      * Set the process id.
52      *
53      * @return a reference to this, so the API can be used fluently
54      */
55     PgNotification setProcessId(int processId) {
56         this.processId = processId;
57         return this;
58     }
59 
60     /**
61      * @return the notification channel value
62      */
63     string getChannel() {
64         return channel;
65     }
66 
67     /**
68      * Set the channel value.
69      *
70      * @return a reference to this, so the API can be used fluently
71      */
72     PgNotification setChannel(string channel) {
73         this.channel = channel;
74         return this;
75     }
76 
77     /**
78      * @return the notification payload value
79      */
80     string getPayload() {
81         return payload;
82     }
83 
84     /**
85      * Set the payload value.
86      *
87      * @return a reference to this, so the API can be used fluently
88      */
89     PgNotification setPayload(string payload) {
90         this.payload = payload;
91         return this;
92     }
93 
94     // JsonObject toJson() {
95     //     JsonObject json = new JsonObject();
96     //     PgNotificationConverter.toJson(this, json);
97     //     return json;
98     // }
99 }