/
IWebhookContainerUnion.java
284 lines (270 loc) · 11.3 KB
/
IWebhookContainerUnion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dv8tion.jda.api.entities.channel.unions;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
import net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer;
import net.dv8tion.jda.api.entities.channel.concrete.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildMessageChannel;
import javax.annotation.Nonnull;
/**
* A union representing all channel types that implement {@link net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer}.
* <br>This class extends {@link net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer} and primarily acts as a discovery tool for
* developers to discover some common interfaces that a {@link net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer} could be cast to.
*
* <br>This interface represents the follow concrete channel types:
* <ul>
* <li>{@link TextChannel}</li>
* <li>{@link NewsChannel}</li>
* <li>{@link VoiceChannel}</li>
* <li>{@link StageChannel}</li>
* <li>{@link ForumChannel}</li>
* <li>{@link MediaChannel}</li>
* </ul>
*/
public interface IWebhookContainerUnion extends IWebhookContainer
{
/**
* Casts this union to a {@link TextChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* TextChannel channel = union.asTextChannel();
* TextChannel channel2 = (TextChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#TEXT} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof TextChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link TextChannel}.
*
* @return The channel as a {@link TextChannel}
*/
@Nonnull
TextChannel asTextChannel();
/**
* Casts this union to a {@link NewsChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* NewsChannel channel = union.asNewsChannel();
* NewsChannel channel2 = (NewsChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#NEWS} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof NewsChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link NewsChannel}.
*
* @return The channel as a {@link NewsChannel}
*/
@Nonnull
NewsChannel asNewsChannel();
/**
* Casts this union to a {@link ForumChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* ForumChannel channel = union.asForumChannel();
* ForumChannel channel2 = (ForumChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#FORUM} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof ForumChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link ForumChannel}.
*
* @return The channel as a {@link ForumChannel}
*/
@Nonnull
ForumChannel asForumChannel();
/**
* Casts this union to a {@link MediaChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* MediaChannel channel = union.asMediaChannel();
* MediaChannel channel2 = (MediaChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#MEDIA} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof MediaChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link MediaChannel}.
*
* @return The channel as a {@link MediaChannel}
*/
@Nonnull
MediaChannel asMediaChannel();
/**
* Casts this union to a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* IThreadContainer channel = union.asThreadContainer();
* IThreadContainer channel2 = (IThreadContainer) union;
* </code></pre>
*
* You can use <code>channel instanceof IThreadContainer</code> to validate whether you can call this method.
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}.
*
* @return The channel as a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}
*/
@Nonnull
IThreadContainer asThreadContainer();
/**
* Casts this union to a {@link VoiceChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* VoiceChannel channel = union.asVoiceChannel();
* VoiceChannel channel2 = (VoiceChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#VOICE} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof VoiceChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link VoiceChannel}.
*
* @return The channel as a {@link VoiceChannel}
*/
@Nonnull
VoiceChannel asVoiceChannel();
/**
* Casts this union to a {@link StageChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* StageChannel channel = union.asStageChannel();
* StageChannel channel2 = (StageChannel) union;
* </code></pre>
*
* You can use {@link #getType()} to see if the channel is of type {@link ChannelType#STAGE} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof StageChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link StageChannel}.
*
* @return The channel as a {@link StageChannel}
*/
@Nonnull
StageChannel asStageChannel();
/**
* Casts this union to a {@link GuildMessageChannel}.
* <br>This works for the following channel types represented by this union:
* <ul>
* <li>{@link TextChannel}</li>
* <li>{@link NewsChannel}</li>
* </ul>
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* GuildMessageChannel channel = union.asGuildMessageChannel();
* GuildMessageChannel channel2 = (GuildMessageChannel) union;
* </code></pre>
*
* You can use {@link #getType()}{@link ChannelType#isMessage() .isMessage()} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof GuildMessageChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link GuildMessageChannel}.
*
* @return The channel as a {@link GuildMessageChannel}
*/
@Nonnull
GuildMessageChannel asGuildMessageChannel();
/**
* Casts this union to a {@link StandardGuildChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* StandardGuildChannel channel = union.asStandardGuildChannel();
* StandardGuildChannel channel2 = (StandardGuildChannel) union;
* </code></pre>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link StandardGuildChannel}.
*
* @return The channel as a {@link StandardGuildChannel}
*/
@Nonnull
StandardGuildChannel asStandardGuildChannel();
/**
* Casts this union to a {@link StandardGuildMessageChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* StandardGuildMessageChannel channel = union.asStandardGuildMessageChannel();
* StandardGuildMessageChannel channel2 = (StandardGuildMessageChannel) union;
* </code></pre>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link StandardGuildMessageChannel}.
*
* @return The channel as a {@link StandardGuildMessageChannel}
*/
@Nonnull
StandardGuildMessageChannel asStandardGuildMessageChannel();
/**
* Casts this union to a {@link AudioChannel}.
* This method exists for developer discoverability.
*
* <p>Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* AudioChannel channel = union.asAudioChannel();
* AudioChannel channel2 = (AudioChannel) union;
* </code></pre>
*
* You can use <code>channel instanceof AudioChannel</code> to validate whether you can call this method.
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link AudioChannel}.
*
* @return The channel as a {@link AudioChannel}
*/
@Nonnull
AudioChannel asAudioChannel();
}