View Javadoc
1   /*
2    * Copyright 2014 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  
17  package io.netty5.channel.embedded;
18  
19  import io.netty5.channel.ChannelId;
20  
21  /**
22   * A dummy {@link ChannelId} implementation.
23   */
24  final class EmbeddedChannelId implements ChannelId {
25  
26      private static final long serialVersionUID = -251711922203466130L;
27  
28      static final ChannelId INSTANCE = new EmbeddedChannelId();
29  
30      private EmbeddedChannelId() { }
31  
32      @Override
33      public String asShortText() {
34          return toString();
35      }
36  
37      @Override
38      public String asLongText() {
39          return toString();
40      }
41  
42      @Override
43      public int compareTo(final ChannelId o) {
44          if (o instanceof EmbeddedChannelId) {
45              return 0;
46          }
47  
48          return asLongText().compareTo(o.asLongText());
49      }
50  
51      @Override
52      public int hashCode() {
53          return 0;
54      }
55  
56      @Override
57      public boolean equals(Object obj) {
58          return obj instanceof EmbeddedChannelId;
59      }
60  
61      @Override
62      public String toString() {
63          return "embedded";
64      }
65  }