/
GuildMessageChannelUnion.java
233 lines (221 loc) · 9.07 KB
/
GuildMessageChannelUnion.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
/*
* 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.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 GuildMessageChannel}.
* <br>This class extends {@link GuildMessageChannel} and primarily acts as a discovery tool for
* developers to discover some common interfaces that a {@link GuildMessageChannel} 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 ThreadChannel}</li>
* </ul>
*/
public interface GuildMessageChannelUnion extends GuildMessageChannel
{
/**
* Casts this union to a {@link TextChannel}.
* This method exists for developer discoverability.
*
* 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.
*
* 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 ThreadChannel}.
* This method exists for developer discoverability.
*
* Note: This is effectively equivalent to using the cast operator:
* <pre><code>
* //These are the same!
* ThreadChannel channel = union.asThreadChannel();
* ThreadChannel channel2 = (ThreadChannel) union;
* </code></pre>
*
* You can use {@link #getType()}{@link ChannelType#isThread() .isThread()} to validate
* whether you can call this method in addition to normal instanceof checks: <code>channel instanceof ThreadChannel</code>
*
* @throws IllegalStateException
* If the channel represented by this union is not actually a {@link ThreadChannel}.
*
* @return The channel as a {@link ThreadChannel}
*/
@Nonnull
ThreadChannel asThreadChannel();
/**
* Casts this union to a {@link VoiceChannel}.
* This method exists for developer discoverability.
*
* 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.
*
* 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 net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}.
* This method exists for developer discoverability.
*
* 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 StandardGuildChannel}.you can call this method
*
* 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.
*
* 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.
*
* 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();
}