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 
18 module hunt.database.base.impl.Notification;
19 
20 import std.conv;
21 
22 /**
23  * @author <a href="mailto:emad.albloushi@gmail.com">Emad Alblueshi</a>
24  */
25 class Notification {
26 
27     private int processId;
28     private string channel;
29     private string payload;
30 
31     this(int processId, string channel, string payload) {
32         this.processId = processId;
33         this.channel = channel;
34         this.payload = payload;
35     }
36 
37     int getProcessId() {
38         return processId;
39     }
40 
41     string getChannel() {
42         return channel;
43     }
44 
45     string getPayload() {
46         return payload;
47     }
48 
49     override
50     bool opEquals(Object o) {
51         if (this is o) return true;
52         Notification that = cast(Notification) o;
53         if (o is null || that is null) return false;
54         
55         return processId == that.processId &&
56             channel == that.channel &&
57             payload == that.payload;
58     }
59 
60     override
61     size_t toHash() @trusted nothrow {
62         return processId.hashOf + channel.hashOf + payload.hashOf;
63     }
64 
65     override
66     string toString() {
67         return "NotificationResponse{" ~
68             "processId=" ~ processId.to!string() ~
69             ", channel='" ~ channel ~ "\'" ~
70             ", payload='" ~ payload ~ "\'" ~
71             "}";
72     }
73 }