View Javadoc
1   /*
2    * Copyright 2021 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.channel.unix;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.ByteBufHolder;
20  import io.netty.channel.DefaultAddressedEnvelope;
21  
22  /**
23   * The message container that is used for {@link DomainDatagramChannel} to communicate with the remote peer.
24   */
25  public final class DomainDatagramPacket
26          extends DefaultAddressedEnvelope<ByteBuf, DomainSocketAddress> implements ByteBufHolder {
27  
28      /**
29       * Create a new instance with the specified packet {@code data} and {@code recipient} address.
30       */
31      public DomainDatagramPacket(ByteBuf data, DomainSocketAddress recipient) {
32          super(data, recipient);
33      }
34  
35      /**
36       * Create a new instance with the specified packet {@code data}, {@code recipient} address, and {@code sender}
37       * address.
38       */
39      public DomainDatagramPacket(ByteBuf data, DomainSocketAddress recipient, DomainSocketAddress sender) {
40          super(data, recipient, sender);
41      }
42  
43      @Override
44      public DomainDatagramPacket copy() {
45          return replace(content().copy());
46      }
47  
48      @Override
49      public DomainDatagramPacket duplicate() {
50          return replace(content().duplicate());
51      }
52  
53      @Override
54      public DomainDatagramPacket replace(ByteBuf content) {
55          return new DomainDatagramPacket(content, recipient(), sender());
56      }
57  
58      @Override
59      public DomainDatagramPacket retain() {
60          super.retain();
61          return this;
62      }
63  
64      @Override
65      public DomainDatagramPacket retain(int increment) {
66          super.retain(increment);
67          return this;
68      }
69  
70      @Override
71      public DomainDatagramPacket retainedDuplicate() {
72          return replace(content().retainedDuplicate());
73      }
74  
75      @Override
76      public DomainDatagramPacket touch() {
77          super.touch();
78          return this;
79      }
80  
81      @Override
82      public DomainDatagramPacket touch(Object hint) {
83          super.touch(hint);
84          return this;
85      }
86  }