-
-
Notifications
You must be signed in to change notification settings - Fork 720
/
IWebhookContainerUnion.java
188 lines (177 loc) · 7.05 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
/*
* 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.*;
import javax.annotation.Nonnull;
/**
* A union representing all channel types that implement {@link IWebhookContainer}.
* <br>This class extends {@link IWebhookContainer} and primarily acts as a discovery tool for
* developers to discover some common interfaces that a {@link IWebhookContainer} could be cast to.
*
* <br>This interface represents the follow concrete channel types:
* <ul>
* <li>{@link TextChannel}</li>
* <li>{@link NewsChannel}</li>
* </ul>
*/
public interface IWebhookContainerUnion extends IWebhookContainer
{
/**
* 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();
//TODO: Add asForumChannel
/**
* Casts this union to a {@link 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 IThreadContainer}.
*
* @return The channel as a {@link IThreadContainer}
*/
@Nonnull
IThreadContainer asThreadContainer();
/**
* 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 GuildMessageChannel}.
* <br>This works for the following channel types represented by this union:
* <ul>
* <li>{@link TextChannel}</li>
* <li>{@link NewsChannel}</li>
* </ul>
*
* 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.
*
* 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();
}