View Javadoc
1   /*
2    * Copyright 2020 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.example.stomp.websocket;
17  
18  import io.netty.channel.Channel;
19  import io.netty.util.internal.ObjectUtil;
20  
21  public final class StompSubscription {
22  
23      private final String id;
24      private final String destination;
25      private final Channel channel;
26  
27      public StompSubscription(String id, String destination, Channel channel) {
28          this.id = ObjectUtil.checkNotNull(id, "id");
29          this.destination = ObjectUtil.checkNotNull(destination, "destination");
30          this.channel = ObjectUtil.checkNotNull(channel, "channel");
31      }
32  
33      public String id() {
34          return id;
35      }
36  
37      public String destination() {
38          return destination;
39      }
40  
41      public Channel channel() {
42          return channel;
43      }
44  
45      @Override
46      public boolean equals(Object obj) {
47          if (this == obj) {
48              return true;
49          }
50  
51          if (obj == null || getClass() != obj.getClass()) {
52              return false;
53          }
54  
55          StompSubscription that = (StompSubscription) obj;
56  
57          if (!id.equals(that.id)) {
58              return false;
59          }
60  
61          if (!destination.equals(that.destination)) {
62              return false;
63          }
64  
65          return channel.equals(that.channel);
66      }
67  
68      @Override
69      public int hashCode() {
70          int result = id.hashCode();
71          result = 31 * result + destination.hashCode();
72          result = 31 * result + channel.hashCode();
73          return result;
74      }
75  }