Package org.javacord.api.util
Interface Specializable<S>
-
- Type Parameters:
S- The base type of which subclasses are eligible to be cast.
- All Known Subinterfaces:
ActionRow,ApplicationCommand,AudioSource,AudioSourceBaseDelegate,BufferableAudioSource,Button,Categorizable,Channel,ChannelCategory,ChannelSpecialization,ContextMenu,CustomEmoji,DownloadableAudioSource,Emoji,HighLevelComponent,Interaction,KnownCustomEmoji,LowLevelComponent,MessageComponentInteraction,MessageContextMenu,PauseableAudioSource,PrivateChannel,RegularServerChannel,SeekableAudioSource,SelectMenu,SelectMenuInteraction,ServerChannel,ServerForumChannel,ServerStageVoiceChannel,ServerTextChannel,ServerThreadChannel,ServerVoiceChannel,SlashCommand,TextChannel,TextInput,UnknownRegularServerChannel,UnknownServerChannel,UserContextMenu,VoiceChannel
- All Known Implementing Classes:
AudioSourceBase,SilentAudioSource
public interface Specializable<S>An object that may be specialized further and recast as a subclass.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default <T extends S>
java.util.Optional<T>as(java.lang.Class<T> type)Get this instance as a desired subtype.
-
-
-
Method Detail
-
as
default <T extends S> java.util.Optional<T> as(java.lang.Class<T> type)
Get this instance as a desired subtype.If the instance is not castable to the specified type, the
Optionalwill be empty.- Type Parameters:
T- The desired type.- Parameters:
type- The type as which to obtain this instance.- Returns:
- Returns an
Optionalof this instance if it could be cast, otherwise an empty result. - Throws:
java.lang.NullPointerException- If the type isnull.
-
-