1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.codec.dns;
17
18 import io.netty5.util.internal.UnstableApi;
19
20 import static java.util.Objects.requireNonNull;
21
22
23
24
25 @UnstableApi
26 public class DefaultDnsResponse extends AbstractDnsMessage implements DnsResponse {
27
28 private boolean authoritativeAnswer;
29 private boolean truncated;
30 private boolean recursionAvailable;
31 private DnsResponseCode code;
32
33
34
35
36
37
38
39 public DefaultDnsResponse(int id) {
40 this(id, DnsOpCode.QUERY, DnsResponseCode.NOERROR);
41 }
42
43
44
45
46
47
48
49 public DefaultDnsResponse(int id, DnsOpCode opCode) {
50 this(id, opCode, DnsResponseCode.NOERROR);
51 }
52
53
54
55
56
57
58
59
60 public DefaultDnsResponse(int id, DnsOpCode opCode, DnsResponseCode code) {
61 super(id, opCode);
62 setCode(code);
63 }
64
65 @Override
66 public boolean isAuthoritativeAnswer() {
67 return authoritativeAnswer;
68 }
69
70 @Override
71 public DnsResponse setAuthoritativeAnswer(boolean authoritativeAnswer) {
72 this.authoritativeAnswer = authoritativeAnswer;
73 return this;
74 }
75
76 @Override
77 public boolean isTruncated() {
78 return truncated;
79 }
80
81 @Override
82 public DnsResponse setTruncated(boolean truncated) {
83 this.truncated = truncated;
84 return this;
85 }
86
87 @Override
88 public boolean isRecursionAvailable() {
89 return recursionAvailable;
90 }
91
92 @Override
93 public DnsResponse setRecursionAvailable(boolean recursionAvailable) {
94 this.recursionAvailable = recursionAvailable;
95 return this;
96 }
97
98 @Override
99 public DnsResponseCode code() {
100 return code;
101 }
102
103 @Override
104 public DnsResponse setCode(DnsResponseCode code) {
105 this.code = requireNonNull(code, "code");
106 return this;
107 }
108
109 @Override
110 public DnsResponse setId(int id) {
111 return (DnsResponse) super.setId(id);
112 }
113
114 @Override
115 public DnsResponse setOpCode(DnsOpCode opCode) {
116 return (DnsResponse) super.setOpCode(opCode);
117 }
118
119 @Override
120 public DnsResponse setRecursionDesired(boolean recursionDesired) {
121 return (DnsResponse) super.setRecursionDesired(recursionDesired);
122 }
123
124 @Override
125 public DnsResponse setZ(int z) {
126 return (DnsResponse) super.setZ(z);
127 }
128
129 @Override
130 public DnsResponse setRecord(DnsSection section, DnsRecord record) {
131 return (DnsResponse) super.setRecord(section, record);
132 }
133
134 @Override
135 public DnsResponse addRecord(DnsSection section, DnsRecord record) {
136 return (DnsResponse) super.addRecord(section, record);
137 }
138
139 @Override
140 public DnsResponse addRecord(DnsSection section, int index, DnsRecord record) {
141 return (DnsResponse) super.addRecord(section, index, record);
142 }
143
144 @Override
145 public DnsResponse clear(DnsSection section) {
146 return (DnsResponse) super.clear(section);
147 }
148
149 @Override
150 public DnsResponse clear() {
151 return (DnsResponse) super.clear();
152 }
153
154 @Override
155 public DnsResponse touch() {
156 return (DnsResponse) super.touch();
157 }
158
159 @Override
160 public DnsResponse touch(Object hint) {
161 return (DnsResponse) super.touch(hint);
162 }
163
164 @Override
165 public DnsResponse retain() {
166 return (DnsResponse) super.retain();
167 }
168
169 @Override
170 public DnsResponse retain(int increment) {
171 return (DnsResponse) super.retain(increment);
172 }
173
174 @Override
175 public String toString() {
176 return DnsMessageUtil.appendResponse(new StringBuilder(128), this).toString();
177 }
178 }