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:
AudioSource,AudioSourceBaseDelegate,BufferableAudioSource,Categorizable,Channel,ChannelCategory,ChannelSpecialization,CustomEmoji,DownloadableAudioSource,Emoji,GroupChannel,KnownCustomEmoji,PauseableAudioSource,PrivateChannel,SeekableAudioSource,ServerChannel,ServerStageVoiceChannel,ServerTextChannel,ServerVoiceChannel,TextChannel,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>
Optional<T>as(Class<T> type)Get this instance as a desired subtype.
-
-
-
Method Detail
-
as
default <T extends S> Optional<T> as(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:
NullPointerException- If the type isnull.
-
-