commonMain.dev.inmo.tgbotapi.extensions.utils.ClassCasts.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tgbotapi.utils-jvm Show documentation
Show all versions of tgbotapi.utils-jvm Show documentation
Additional extensions for core part of tgbotapi
@file:Suppress("NOTHING_TO_INLINE", "unused", "UNCHECKED_CAST")
package dev.inmo.tgbotapi.extensions.utils
import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.audio.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.document.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.gif.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.photo.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.video.*
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.results.voice.*
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.*
import dev.inmo.tgbotapi.types.InlineQueries.query.*
import dev.inmo.tgbotapi.types.abstracts.WithOptionalLanguageCode
import dev.inmo.tgbotapi.types.actions.*
import dev.inmo.tgbotapi.types.buttons.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.member.*
import dev.inmo.tgbotapi.types.dice.*
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.message.*
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
import dev.inmo.tgbotapi.types.message.textsources.*
import dev.inmo.tgbotapi.types.passport.*
import dev.inmo.tgbotapi.types.passport.decrypted.*
import dev.inmo.tgbotapi.types.passport.decrypted.abstracts.*
import dev.inmo.tgbotapi.types.passport.encrypted.*
import dev.inmo.tgbotapi.types.passport.encrypted.abstracts.*
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.queries.callback.*
import dev.inmo.tgbotapi.types.update.*
import dev.inmo.tgbotapi.types.update.abstracts.*
import dev.inmo.tgbotapi.utils.PreviewFeature
@PreviewFeature
inline fun Chat.whenBot(block: (Bot) -> T) = asBot()?.let(block)
@PreviewFeature
inline fun Chat.asBot(): Bot? = this as? Bot
@PreviewFeature
inline fun Chat.requireBot(): Bot = this as Bot
@PreviewFeature
inline fun Chat.whenCommonBot(block: (CommonBot) -> T) = asCommonBot()?.let(block)
@PreviewFeature
inline fun Chat.asCommonBot(): CommonBot? = this as? CommonBot
@PreviewFeature
inline fun Chat.requireCommonBot(): CommonBot = this as CommonBot
@PreviewFeature
inline fun Chat.whenCommonUser(block: (CommonUser) -> T) = asCommonUser()?.let(block)
@PreviewFeature
inline fun Chat.asCommonUser(): CommonUser? = this as? CommonUser
@PreviewFeature
inline fun Chat.requireCommonUser(): CommonUser = this as CommonUser
@PreviewFeature
inline fun Chat.whenExtendedBot(block: (ExtendedBot) -> T) = asExtendedBot()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedBot(): ExtendedBot? = this as? ExtendedBot
@PreviewFeature
inline fun Chat.requireExtendedBot(): ExtendedBot = this as ExtendedBot
@PreviewFeature
inline fun Chat.whenUser(block: (User) -> T) = asUser()?.let(block)
@PreviewFeature
inline fun Chat.asUser(): User? = this as? User
@PreviewFeature
inline fun Chat.requireUser(): User = this as User
@PreviewFeature
inline fun Chat.whenChannelChat(block: (ChannelChat) -> T) = asChannelChat()?.let(block)
@PreviewFeature
inline fun Chat.asChannelChat(): ChannelChat? = this as? ChannelChat
@PreviewFeature
inline fun Chat.requireChannelChat(): ChannelChat = this as ChannelChat
@PreviewFeature
inline fun Chat.whenGroupChat(block: (GroupChat) -> T) = asGroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asGroupChat(): GroupChat? = this as? GroupChat
@PreviewFeature
inline fun Chat.requireGroupChat(): GroupChat = this as GroupChat
@PreviewFeature
inline fun Chat.whenPrivateChat(block: (PrivateChat) -> T) = asPrivateChat()?.let(block)
@PreviewFeature
inline fun Chat.asPrivateChat(): PrivateChat? = this as? PrivateChat
@PreviewFeature
inline fun Chat.requirePrivateChat(): PrivateChat = this as PrivateChat
@PreviewFeature
inline fun Chat.whenPublicChat(block: (PublicChat) -> T) = asPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asPublicChat(): PublicChat? = this as? PublicChat
@PreviewFeature
inline fun Chat.requirePublicChat(): PublicChat = this as PublicChat
@PreviewFeature
inline fun Chat.whenSuperPublicChat(block: (SuperPublicChat) -> T) = asSuperPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asSuperPublicChat(): SuperPublicChat? = this as? SuperPublicChat
@PreviewFeature
inline fun Chat.requireSuperPublicChat(): SuperPublicChat = this as SuperPublicChat
@PreviewFeature
inline fun Chat.whenSupergroupChat(block: (SupergroupChat) -> T) = asSupergroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asSupergroupChat(): SupergroupChat? = this as? SupergroupChat
@PreviewFeature
inline fun Chat.requireSupergroupChat(): SupergroupChat = this as SupergroupChat
@PreviewFeature
inline fun Chat.whenUnknownChatType(block: (UnknownChatType) -> T) = asUnknownChatType()?.let(block)
@PreviewFeature
inline fun Chat.asUnknownChatType(): UnknownChatType? = this as? UnknownChatType
@PreviewFeature
inline fun Chat.requireUnknownChatType(): UnknownChatType = this as UnknownChatType
@PreviewFeature
inline fun Chat.whenUsernameChat(block: (UsernameChat) -> T) = asUsernameChat()?.let(block)
@PreviewFeature
inline fun Chat.asUsernameChat(): UsernameChat? = this as? UsernameChat
@PreviewFeature
inline fun Chat.requireUsernameChat(): UsernameChat = this as UsernameChat
@PreviewFeature
inline fun Chat.whenExtendedChannelChat(block: (ExtendedChannelChat) -> T) = asExtendedChannelChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedChannelChat(): ExtendedChannelChat? = this as? ExtendedChannelChat
@PreviewFeature
inline fun Chat.requireExtendedChannelChat(): ExtendedChannelChat = this as ExtendedChannelChat
@PreviewFeature
inline fun Chat.whenExtendedChat(block: (ExtendedChat) -> T) = asExtendedChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedChat(): ExtendedChat? = this as? ExtendedChat
@PreviewFeature
inline fun Chat.requireExtendedChat(): ExtendedChat = this as ExtendedChat
@PreviewFeature
inline fun Chat.whenExtendedGroupChat(block: (ExtendedGroupChat) -> T) = asExtendedGroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedGroupChat(): ExtendedGroupChat? = this as? ExtendedGroupChat
@PreviewFeature
inline fun Chat.requireExtendedGroupChat(): ExtendedGroupChat = this as ExtendedGroupChat
@PreviewFeature
inline fun Chat.whenExtendedPrivateChat(block: (ExtendedPrivateChat) -> T) = asExtendedPrivateChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedPrivateChat(): ExtendedPrivateChat? = this as? ExtendedPrivateChat
@PreviewFeature
inline fun Chat.requireExtendedPrivateChat(): ExtendedPrivateChat = this as ExtendedPrivateChat
@PreviewFeature
inline fun Chat.whenExtendedPublicChat(block: (ExtendedPublicChat) -> T) = asExtendedPublicChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedPublicChat(): ExtendedPublicChat? = this as? ExtendedPublicChat
@PreviewFeature
inline fun Chat.requireExtendedPublicChat(): ExtendedPublicChat = this as ExtendedPublicChat
@PreviewFeature
inline fun Chat.whenExtendedSupergroupChat(block: (ExtendedSupergroupChat) -> T) =
asExtendedSupergroupChat()?.let(block)
@PreviewFeature
inline fun Chat.asExtendedSupergroupChat(): ExtendedSupergroupChat? = this as? ExtendedSupergroupChat
@PreviewFeature
inline fun Chat.requireExtendedSupergroupChat(): ExtendedSupergroupChat = this as ExtendedSupergroupChat
@PreviewFeature
inline fun Chat.whenPossiblyPremiumChat(block: (PossiblyPremiumChat) -> T) = asPossiblyPremiumChat()?.let(block)
@PreviewFeature
inline fun Chat.asPossiblyPremiumChat(): PossiblyPremiumChat? = this as? PossiblyPremiumChat
@PreviewFeature
inline fun Chat.requirePossiblyPremiumChat(): PossiblyPremiumChat = this as PossiblyPremiumChat
@PreviewFeature
inline fun Chat.whenAbleToAddInAttachmentMenuChat(block: (AbleToAddInAttachmentMenuChat) -> T) =
asAbleToAddInAttachmentMenuChat()?.let(block)
@PreviewFeature
inline fun Chat.asAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat? =
this as? AbleToAddInAttachmentMenuChat
@PreviewFeature
inline fun Chat.requireAbleToAddInAttachmentMenuChat(): AbleToAddInAttachmentMenuChat =
this as AbleToAddInAttachmentMenuChat
@PreviewFeature
inline fun CallbackQuery.whenDataCallbackQuery(block: (DataCallbackQuery) -> T) = asDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asDataCallbackQuery(): DataCallbackQuery? = this as? DataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireDataCallbackQuery(): DataCallbackQuery = this as DataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T) =
asGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asGameShortNameCallbackQuery(): GameShortNameCallbackQuery? =
this as? GameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireGameShortNameCallbackQuery(): GameShortNameCallbackQuery =
this as GameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenInlineMessageIdCallbackQuery(block: (InlineMessageIdCallbackQuery) -> T) =
asInlineMessageIdCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery? =
this as? InlineMessageIdCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireInlineMessageIdCallbackQuery(): InlineMessageIdCallbackQuery =
this as InlineMessageIdCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenInlineMessageIdDataCallbackQuery(block: (InlineMessageIdDataCallbackQuery) -> T) =
asInlineMessageIdDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery? =
this as? InlineMessageIdDataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireInlineMessageIdDataCallbackQuery(): InlineMessageIdDataCallbackQuery =
this as InlineMessageIdDataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenInlineMessageIdGameShortNameCallbackQuery(block: (InlineMessageIdGameShortNameCallbackQuery) -> T) =
asInlineMessageIdGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery? =
this as? InlineMessageIdGameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireInlineMessageIdGameShortNameCallbackQuery(): InlineMessageIdGameShortNameCallbackQuery =
this as InlineMessageIdGameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenMessageCallbackQuery(block: (MessageCallbackQuery) -> T) =
asMessageCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageCallbackQuery(): MessageCallbackQuery? = this as? MessageCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireMessageCallbackQuery(): MessageCallbackQuery = this as MessageCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenMessageDataCallbackQuery(block: (MessageDataCallbackQuery) -> T) =
asMessageDataCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageDataCallbackQuery(): MessageDataCallbackQuery? = this as? MessageDataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireMessageDataCallbackQuery(): MessageDataCallbackQuery = this as MessageDataCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T) =
asMessageGameShortNameCallbackQuery()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery? =
this as? MessageGameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.requireMessageGameShortNameCallbackQuery(): MessageGameShortNameCallbackQuery =
this as MessageGameShortNameCallbackQuery
@PreviewFeature
inline fun CallbackQuery.whenUnknownCallbackQueryType(block: (UnknownCallbackQueryType) -> T) =
asUnknownCallbackQueryType()?.let(block)
@PreviewFeature
inline fun CallbackQuery.asUnknownCallbackQueryType(): UnknownCallbackQueryType? = this as? UnknownCallbackQueryType
@PreviewFeature
inline fun CallbackQuery.requireUnknownCallbackQueryType(): UnknownCallbackQueryType = this as UnknownCallbackQueryType
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorDataField(block: (PassportElementErrorDataField) -> T) =
asPassportElementErrorDataField()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorDataField(): PassportElementErrorDataField? =
this as? PassportElementErrorDataField
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorDataField(): PassportElementErrorDataField =
this as PassportElementErrorDataField
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorFile(block: (PassportElementErrorFile) -> T) =
asPassportElementErrorFile()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFile(): PassportElementErrorFile? =
this as? PassportElementErrorFile
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorFile(): PassportElementErrorFile =
this as PassportElementErrorFile
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorFiles(block: (PassportElementErrorFiles) -> T) =
asPassportElementErrorFiles()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFiles(): PassportElementErrorFiles? =
this as? PassportElementErrorFiles
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorFiles(): PassportElementErrorFiles =
this as PassportElementErrorFiles
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorFrontSide(block: (PassportElementErrorFrontSide) -> T) =
asPassportElementErrorFrontSide()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorFrontSide(): PassportElementErrorFrontSide? =
this as? PassportElementErrorFrontSide
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorFrontSide(): PassportElementErrorFrontSide =
this as PassportElementErrorFrontSide
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorReverseSide(block: (PassportElementErrorReverseSide) -> T) =
asPassportElementErrorReverseSide()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorReverseSide(): PassportElementErrorReverseSide? =
this as? PassportElementErrorReverseSide
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorReverseSide(): PassportElementErrorReverseSide =
this as PassportElementErrorReverseSide
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorSelfie(block: (PassportElementErrorSelfie) -> T) =
asPassportElementErrorSelfie()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorSelfie(): PassportElementErrorSelfie? =
this as? PassportElementErrorSelfie
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorSelfie(): PassportElementErrorSelfie =
this as PassportElementErrorSelfie
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorTranslationFile(block: (PassportElementErrorTranslationFile) -> T) =
asPassportElementErrorTranslationFile()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorTranslationFile(): PassportElementErrorTranslationFile? =
this as? PassportElementErrorTranslationFile
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorTranslationFile(): PassportElementErrorTranslationFile =
this as PassportElementErrorTranslationFile
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorTranslationFiles(block: (PassportElementErrorTranslationFiles) -> T) =
asPassportElementErrorTranslationFiles()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles? =
this as? PassportElementErrorTranslationFiles
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorTranslationFiles(): PassportElementErrorTranslationFiles =
this as PassportElementErrorTranslationFiles
@PreviewFeature
inline fun PassportElementError.whenPassportElementErrorUnspecified(block: (PassportElementErrorUnspecified) -> T) =
asPassportElementErrorUnspecified()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementErrorUnspecified(): PassportElementErrorUnspecified? =
this as? PassportElementErrorUnspecified
@PreviewFeature
inline fun PassportElementError.requirePassportElementErrorUnspecified(): PassportElementErrorUnspecified =
this as PassportElementErrorUnspecified
@PreviewFeature
inline fun PassportElementError.whenPassportElementFileError(block: (PassportElementFileError) -> T) =
asPassportElementFileError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementFileError(): PassportElementFileError? =
this as? PassportElementFileError
@PreviewFeature
inline fun PassportElementError.requirePassportElementFileError(): PassportElementFileError =
this as PassportElementFileError
@PreviewFeature
inline fun PassportElementError.whenPassportElementFilesError(block: (PassportElementFilesError) -> T) =
asPassportElementFilesError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportElementFilesError(): PassportElementFilesError? =
this as? PassportElementFilesError
@PreviewFeature
inline fun PassportElementError.requirePassportElementFilesError(): PassportElementFilesError =
this as PassportElementFilesError
@PreviewFeature
inline fun PassportElementError.whenPassportMultipleElementsError(block: (PassportMultipleElementsError) -> T) =
asPassportMultipleElementsError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportMultipleElementsError(): PassportMultipleElementsError? =
this as? PassportMultipleElementsError
@PreviewFeature
inline fun PassportElementError.requirePassportMultipleElementsError(): PassportMultipleElementsError =
this as PassportMultipleElementsError
@PreviewFeature
inline fun PassportElementError.whenPassportSingleElementError(block: (PassportSingleElementError) -> T) =
asPassportSingleElementError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asPassportSingleElementError(): PassportSingleElementError? =
this as? PassportSingleElementError
@PreviewFeature
inline fun PassportElementError.requirePassportSingleElementError(): PassportSingleElementError =
this as PassportSingleElementError
@PreviewFeature
inline fun PassportElementError.whenUnknownPassportElementError(block: (UnknownPassportElementError) -> T) =
asUnknownPassportElementError()?.let(block)
@PreviewFeature
inline fun PassportElementError.asUnknownPassportElementError(): UnknownPassportElementError? =
this as? UnknownPassportElementError
@PreviewFeature
inline fun PassportElementError.requireUnknownPassportElementError(): UnknownPassportElementError =
this as UnknownPassportElementError
@PreviewFeature
inline fun EncryptedPassportElement.whenBankStatement(block: (BankStatement) -> T) = asBankStatement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asBankStatement(): BankStatement? = this as? BankStatement
@PreviewFeature
inline fun EncryptedPassportElement.requireBankStatement(): BankStatement = this as BankStatement
@PreviewFeature
inline fun EncryptedPassportElement.whenCommonPassport(block: (CommonPassport) -> T) =
asCommonPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asCommonPassport(): CommonPassport? = this as? CommonPassport
@PreviewFeature
inline fun EncryptedPassportElement.requireCommonPassport(): CommonPassport = this as CommonPassport
@PreviewFeature
inline fun EncryptedPassportElement.whenDriverLicense(block: (DriverLicense) -> T) = asDriverLicense()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asDriverLicense(): DriverLicense? = this as? DriverLicense
@PreviewFeature
inline fun EncryptedPassportElement.requireDriverLicense(): DriverLicense = this as DriverLicense
@PreviewFeature
inline fun EncryptedPassportElement.whenEmail(block: (Email) -> T) = asEmail()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEmail(): Email? = this as? Email
@PreviewFeature
inline fun EncryptedPassportElement.requireEmail(): Email = this as Email
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedAddress(block: (EncryptedAddress) -> T) =
asEncryptedAddress()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedAddress(): EncryptedAddress? = this as? EncryptedAddress
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedAddress(): EncryptedAddress = this as EncryptedAddress
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPersonalDetails(block: (EncryptedPersonalDetails) -> T) =
asEncryptedPersonalDetails()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPersonalDetails(): EncryptedPersonalDetails? =
this as? EncryptedPersonalDetails
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPersonalDetails(): EncryptedPersonalDetails =
this as EncryptedPersonalDetails
@PreviewFeature
inline fun EncryptedPassportElement.whenIdentityCard(block: (IdentityCard) -> T) = asIdentityCard()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asIdentityCard(): IdentityCard? = this as? IdentityCard
@PreviewFeature
inline fun EncryptedPassportElement.requireIdentityCard(): IdentityCard = this as IdentityCard
@PreviewFeature
inline fun EncryptedPassportElement.whenInternalPassport(block: (InternalPassport) -> T) =
asInternalPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asInternalPassport(): InternalPassport? = this as? InternalPassport
@PreviewFeature
inline fun EncryptedPassportElement.requireInternalPassport(): InternalPassport = this as InternalPassport
@PreviewFeature
inline fun EncryptedPassportElement.whenPassport(block: (Passport) -> T) = asPassport()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPassport(): Passport? = this as? Passport
@PreviewFeature
inline fun EncryptedPassportElement.requirePassport(): Passport = this as Passport
@PreviewFeature
inline fun EncryptedPassportElement.whenPassportRegistration(block: (PassportRegistration) -> T) =
asPassportRegistration()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPassportRegistration(): PassportRegistration? = this as? PassportRegistration
@PreviewFeature
inline fun EncryptedPassportElement.requirePassportRegistration(): PassportRegistration = this as PassportRegistration
@PreviewFeature
inline fun EncryptedPassportElement.whenPhoneNumber(block: (PhoneNumber) -> T) = asPhoneNumber()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asPhoneNumber(): PhoneNumber? = this as? PhoneNumber
@PreviewFeature
inline fun EncryptedPassportElement.requirePhoneNumber(): PhoneNumber = this as PhoneNumber
@PreviewFeature
inline fun EncryptedPassportElement.whenRentalAgreement(block: (RentalAgreement) -> T) =
asRentalAgreement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asRentalAgreement(): RentalAgreement? = this as? RentalAgreement
@PreviewFeature
inline fun EncryptedPassportElement.requireRentalAgreement(): RentalAgreement = this as RentalAgreement
@PreviewFeature
inline fun EncryptedPassportElement.whenTemporaryRegistration(block: (TemporaryRegistration) -> T) =
asTemporaryRegistration()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asTemporaryRegistration(): TemporaryRegistration? = this as? TemporaryRegistration
@PreviewFeature
inline fun EncryptedPassportElement.requireTemporaryRegistration(): TemporaryRegistration =
this as TemporaryRegistration
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableFilesCollection(block: (EncryptedPassportElementWithTranslatableFilesCollection) -> T) =
asEncryptedPassportElementWithTranslatableFilesCollection()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection? =
this as? EncryptedPassportElementWithTranslatableFilesCollection
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableFilesCollection(): EncryptedPassportElementWithTranslatableFilesCollection =
this as EncryptedPassportElementWithTranslatableFilesCollection
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithTranslatableIDDocument(block: (EncryptedPassportElementWithTranslatableIDDocument) -> T) =
asEncryptedPassportElementWithTranslatableIDDocument()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument? =
this as? EncryptedPassportElementWithTranslatableIDDocument
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithTranslatableIDDocument(): EncryptedPassportElementWithTranslatableIDDocument =
this as EncryptedPassportElementWithTranslatableIDDocument
@PreviewFeature
inline fun EncryptedPassportElement.whenUtilityBill(block: (UtilityBill) -> T) = asUtilityBill()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asUtilityBill(): UtilityBill? = this as? UtilityBill
@PreviewFeature
inline fun EncryptedPassportElement.requireUtilityBill(): UtilityBill = this as UtilityBill
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFilesCollection(block: (EncryptedPassportElementWithFilesCollection) -> T) =
asEncryptedPassportElementWithFilesCollection()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection? =
this as? EncryptedPassportElementWithFilesCollection
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFilesCollection(): EncryptedPassportElementWithFilesCollection =
this as EncryptedPassportElementWithFilesCollection
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementTranslatable(block: (EncryptedPassportElementTranslatable) -> T) =
asEncryptedPassportElementTranslatable()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable? =
this as? EncryptedPassportElementTranslatable
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementTranslatable(): EncryptedPassportElementTranslatable =
this as EncryptedPassportElementTranslatable
@PreviewFeature
inline fun EncryptedPassportElement.whenUnknownEncryptedPassportElement(block: (UnknownEncryptedPassportElement) -> T) =
asUnknownEncryptedPassportElement()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement? =
this as? UnknownEncryptedPassportElement
@PreviewFeature
inline fun EncryptedPassportElement.requireUnknownEncryptedPassportElement(): UnknownEncryptedPassportElement =
this as UnknownEncryptedPassportElement
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithData(block: (EncryptedPassportElementWithData) -> T) =
asEncryptedPassportElementWithData()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithData(): EncryptedPassportElementWithData? =
this as? EncryptedPassportElementWithData
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithData(): EncryptedPassportElementWithData =
this as EncryptedPassportElementWithData
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithEmail(block: (EncryptedPassportElementWithEmail) -> T) =
asEncryptedPassportElementWithEmail()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail? =
this as? EncryptedPassportElementWithEmail
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithEmail(): EncryptedPassportElementWithEmail =
this as EncryptedPassportElementWithEmail
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithFrontSide(block: (EncryptedPassportElementWithFrontSide) -> T) =
asEncryptedPassportElementWithFrontSide()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide? =
this as? EncryptedPassportElementWithFrontSide
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithFrontSide(): EncryptedPassportElementWithFrontSide =
this as EncryptedPassportElementWithFrontSide
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithPhoneNumber(block: (EncryptedPassportElementWithPhoneNumber) -> T) =
asEncryptedPassportElementWithPhoneNumber()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber? =
this as? EncryptedPassportElementWithPhoneNumber
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithPhoneNumber(): EncryptedPassportElementWithPhoneNumber =
this as EncryptedPassportElementWithPhoneNumber
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithReverseSide(block: (EncryptedPassportElementWithReverseSide) -> T) =
asEncryptedPassportElementWithReverseSide()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide? =
this as? EncryptedPassportElementWithReverseSide
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithReverseSide(): EncryptedPassportElementWithReverseSide =
this as EncryptedPassportElementWithReverseSide
@PreviewFeature
inline fun EncryptedPassportElement.whenEncryptedPassportElementWithSelfie(block: (EncryptedPassportElementWithSelfie) -> T) =
asEncryptedPassportElementWithSelfie()?.let(block)
@PreviewFeature
inline fun EncryptedPassportElement.asEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie? =
this as? EncryptedPassportElementWithSelfie
@PreviewFeature
inline fun EncryptedPassportElement.requireEncryptedPassportElementWithSelfie(): EncryptedPassportElementWithSelfie =
this as EncryptedPassportElementWithSelfie
@PreviewFeature
inline fun SecureValue.whenAddressSecureValue(block: (AddressSecureValue) -> T) = asAddressSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asAddressSecureValue(): AddressSecureValue? = this as? AddressSecureValue
@PreviewFeature
inline fun SecureValue.requireAddressSecureValue(): AddressSecureValue = this as AddressSecureValue
@PreviewFeature
inline fun SecureValue.whenBankStatementSecureValue(block: (BankStatementSecureValue) -> T) =
asBankStatementSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asBankStatementSecureValue(): BankStatementSecureValue? = this as? BankStatementSecureValue
@PreviewFeature
inline fun SecureValue.requireBankStatementSecureValue(): BankStatementSecureValue = this as BankStatementSecureValue
@PreviewFeature
inline fun SecureValue.whenCommonPassportSecureValue(block: (CommonPassportSecureValue) -> T) =
asCommonPassportSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asCommonPassportSecureValue(): CommonPassportSecureValue? = this as? CommonPassportSecureValue
@PreviewFeature
inline fun SecureValue.requireCommonPassportSecureValue(): CommonPassportSecureValue = this as CommonPassportSecureValue
@PreviewFeature
inline fun SecureValue.whenDriverLicenseSecureValue(block: (DriverLicenseSecureValue) -> T) =
asDriverLicenseSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asDriverLicenseSecureValue(): DriverLicenseSecureValue? = this as? DriverLicenseSecureValue
@PreviewFeature
inline fun SecureValue.requireDriverLicenseSecureValue(): DriverLicenseSecureValue = this as DriverLicenseSecureValue
@PreviewFeature
inline fun SecureValue.whenIdentityCardSecureValue(block: (IdentityCardSecureValue) -> T) =
asIdentityCardSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asIdentityCardSecureValue(): IdentityCardSecureValue? = this as? IdentityCardSecureValue
@PreviewFeature
inline fun SecureValue.requireIdentityCardSecureValue(): IdentityCardSecureValue = this as IdentityCardSecureValue
@PreviewFeature
inline fun SecureValue.whenIdentityWithReverseSideSecureValue(block: (IdentityWithReverseSideSecureValue) -> T) =
asIdentityWithReverseSideSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue? =
this as? IdentityWithReverseSideSecureValue
@PreviewFeature
inline fun SecureValue.requireIdentityWithReverseSideSecureValue(): IdentityWithReverseSideSecureValue =
this as IdentityWithReverseSideSecureValue
@PreviewFeature
inline fun SecureValue.whenInternalPassportSecureValue(block: (InternalPassportSecureValue) -> T) =
asInternalPassportSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asInternalPassportSecureValue(): InternalPassportSecureValue? =
this as? InternalPassportSecureValue
@PreviewFeature
inline fun SecureValue.requireInternalPassportSecureValue(): InternalPassportSecureValue =
this as InternalPassportSecureValue
@PreviewFeature
inline fun SecureValue.whenOtherDocumentsSecureValue(block: (OtherDocumentsSecureValue) -> T) =
asOtherDocumentsSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asOtherDocumentsSecureValue(): OtherDocumentsSecureValue? = this as? OtherDocumentsSecureValue
@PreviewFeature
inline fun SecureValue.requireOtherDocumentsSecureValue(): OtherDocumentsSecureValue = this as OtherDocumentsSecureValue
@PreviewFeature
inline fun SecureValue.whenPassportRegistrationSecureValue(block: (PassportRegistrationSecureValue) -> T) =
asPassportRegistrationSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asPassportRegistrationSecureValue(): PassportRegistrationSecureValue? =
this as? PassportRegistrationSecureValue
@PreviewFeature
inline fun SecureValue.requirePassportRegistrationSecureValue(): PassportRegistrationSecureValue =
this as PassportRegistrationSecureValue
@PreviewFeature
inline fun SecureValue.whenPassportSecureValue(block: (PassportSecureValue) -> T) =
asPassportSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asPassportSecureValue(): PassportSecureValue? = this as? PassportSecureValue
@PreviewFeature
inline fun SecureValue.requirePassportSecureValue(): PassportSecureValue = this as PassportSecureValue
@PreviewFeature
inline fun SecureValue.whenPersonalDetailsSecureValue(block: (PersonalDetailsSecureValue) -> T) =
asPersonalDetailsSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asPersonalDetailsSecureValue(): PersonalDetailsSecureValue? = this as? PersonalDetailsSecureValue
@PreviewFeature
inline fun SecureValue.requirePersonalDetailsSecureValue(): PersonalDetailsSecureValue =
this as PersonalDetailsSecureValue
@PreviewFeature
inline fun SecureValue.whenRentalAgreementSecureValue(block: (RentalAgreementSecureValue) -> T) =
asRentalAgreementSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asRentalAgreementSecureValue(): RentalAgreementSecureValue? = this as? RentalAgreementSecureValue
@PreviewFeature
inline fun SecureValue.requireRentalAgreementSecureValue(): RentalAgreementSecureValue =
this as RentalAgreementSecureValue
@PreviewFeature
inline fun SecureValue.whenTemporalRegistrationSecureValue(block: (TemporalRegistrationSecureValue) -> T) =
asTemporalRegistrationSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue? =
this as? TemporalRegistrationSecureValue
@PreviewFeature
inline fun SecureValue.requireTemporalRegistrationSecureValue(): TemporalRegistrationSecureValue =
this as TemporalRegistrationSecureValue
@PreviewFeature
inline fun SecureValue.whenUtilityBillSecureValue(block: (UtilityBillSecureValue) -> T) =
asUtilityBillSecureValue()?.let(block)
@PreviewFeature
inline fun SecureValue.asUtilityBillSecureValue(): UtilityBillSecureValue? = this as? UtilityBillSecureValue
@PreviewFeature
inline fun SecureValue.requireUtilityBillSecureValue(): UtilityBillSecureValue = this as UtilityBillSecureValue
@PreviewFeature
inline fun SecureValue.whenSecureValueIdentity(block: (SecureValueIdentity) -> T) =
asSecureValueIdentity()?.let(block)
@PreviewFeature
inline fun SecureValue.asSecureValueIdentity(): SecureValueIdentity? = this as? SecureValueIdentity
@PreviewFeature
inline fun SecureValue.requireSecureValueIdentity(): SecureValueIdentity = this as SecureValueIdentity
@PreviewFeature
inline fun SecureValue.whenSecureValueWithData(block: (SecureValueWithData) -> T) =
asSecureValueWithData()?.let(block)
@PreviewFeature
inline fun SecureValue.asSecureValueWithData(): SecureValueWithData? = this as? SecureValueWithData
@PreviewFeature
inline fun SecureValue.requireSecureValueWithData(): SecureValueWithData = this as SecureValueWithData
@PreviewFeature
inline fun SecureValue.whenSecureValueWithFiles(block: (SecureValueWithFiles) -> T) =
asSecureValueWithFiles()?.let(block)
@PreviewFeature
inline fun SecureValue.asSecureValueWithFiles(): SecureValueWithFiles? = this as? SecureValueWithFiles
@PreviewFeature
inline fun SecureValue.requireSecureValueWithFiles(): SecureValueWithFiles = this as SecureValueWithFiles
@PreviewFeature
inline fun SecureValue.whenSecureValueWithReverseSide(block: (SecureValueWithReverseSide) -> T) =
asSecureValueWithReverseSide()?.let(block)
@PreviewFeature
inline fun SecureValue.asSecureValueWithReverseSide(): SecureValueWithReverseSide? = this as? SecureValueWithReverseSide
@PreviewFeature
inline fun SecureValue.requireSecureValueWithReverseSide(): SecureValueWithReverseSide =
this as SecureValueWithReverseSide
@PreviewFeature
inline fun SecureValue.whenSecureValueWithTranslations(block: (SecureValueWithTranslations) -> T) =
asSecureValueWithTranslations()?.let(block)
@PreviewFeature
inline fun SecureValue.asSecureValueWithTranslations(): SecureValueWithTranslations? =
this as? SecureValueWithTranslations
@PreviewFeature
inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTranslations =
this as SecureValueWithTranslations
@PreviewFeature
inline fun Message.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl) -> T) =
asAnonymousGroupContentMessageImpl()?.let(block)
@PreviewFeature
inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl? =
this as? AnonymousGroupContentMessageImpl
@PreviewFeature
inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl =
this as AnonymousGroupContentMessageImpl
@PreviewFeature
inline fun Message.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl) -> T) =
asChannelContentMessageImpl()?.let(block)
@PreviewFeature
inline fun Message.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl? =
this as? UnconnectedFromChannelGroupContentMessageImpl
@PreviewFeature
inline fun Message.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl =
this as UnconnectedFromChannelGroupContentMessageImpl
@PreviewFeature
inline fun Message.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block)
@PreviewFeature
inline fun Message.asPassportMessage(): PassportMessage? = this as? PassportMessage
@PreviewFeature
inline fun Message.requirePassportMessage(): PassportMessage = this as PassportMessage
@PreviewFeature
inline fun Message.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl) -> T) =
asPrivateContentMessageImpl()?.let(block)
@PreviewFeature
inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl? =
this as? PrivateContentMessageImpl
@PreviewFeature
inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl =
this as PrivateContentMessageImpl
@PreviewFeature
inline fun Message.whenChannelEventMessage(block: (ChannelEventMessage) -> T) =
asChannelEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asChannelEventMessage(): ChannelEventMessage? =
this as? ChannelEventMessage
@PreviewFeature
inline fun Message.requireChannelEventMessage(): ChannelEventMessage =
this as ChannelEventMessage
@PreviewFeature
inline fun Message.whenCommonGroupEventMessage(block: (CommonGroupEventMessage) -> T) =
asCommonGroupEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage? =
this as? CommonGroupEventMessage
@PreviewFeature
inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage =
this as CommonGroupEventMessage
@PreviewFeature
inline fun Message.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage) -> T) =
asCommonSupergroupEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage? =
this as? CommonSupergroupEventMessage
@PreviewFeature
inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage =
this as CommonSupergroupEventMessage
@PreviewFeature
inline fun Message.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage) -> T) =
asAnonymousGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage? =
this as? AnonymousGroupContentMessage
@PreviewFeature
inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage =
this as AnonymousGroupContentMessage
@PreviewFeature
inline fun Message.whenChannelContentMessage(block: (ChannelContentMessage) -> T) =
asChannelContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asChannelContentMessage(): ChannelContentMessage? =
this as? ChannelContentMessage
@PreviewFeature
inline fun Message.requireChannelContentMessage(): ChannelContentMessage =
this as ChannelContentMessage
@PreviewFeature
inline fun Message.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage) -> T) =
asConnectedFromChannelGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage? =
this as? ConnectedFromChannelGroupContentMessage
@PreviewFeature
inline fun Message.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage =
this as ConnectedFromChannelGroupContentMessage
@PreviewFeature
inline fun Message.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage) -> T) =
asUnconnectedFromChannelGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage? =
this as? UnconnectedFromChannelGroupContentMessage
@PreviewFeature
inline fun Message.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage =
this as UnconnectedFromChannelGroupContentMessage
@PreviewFeature
inline fun Message.whenChatEventMessage(block: (ChatEventMessage) -> T) =
asChatEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asChatEventMessage(): ChatEventMessage? = this as? ChatEventMessage
@PreviewFeature
inline fun Message.requireChatEventMessage(): ChatEventMessage = this as ChatEventMessage
@PreviewFeature
inline fun Message.whenCommonGroupContentMessage(block: (CommonGroupContentMessage) -> T) =
asCommonGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage? =
this as? CommonGroupContentMessage
@PreviewFeature
inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage =
this as CommonGroupContentMessage
@PreviewFeature
inline fun Message.whenCommonMessage(block: (CommonMessage) -> T) = asCommonMessage()?.let(block)
@PreviewFeature
inline fun Message.asCommonMessage(): CommonMessage? = this as? CommonMessage
@PreviewFeature
inline fun Message.requireCommonMessage(): CommonMessage = this as CommonMessage
@PreviewFeature
inline fun Message.whenContentMessage(block: (ContentMessage) -> T) = asContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asContentMessage(): ContentMessage? = this as? ContentMessage
@PreviewFeature
inline fun Message.requireContentMessage(): ContentMessage = this as ContentMessage
@PreviewFeature
inline fun Message.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage) -> T) =
asFromChannelGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage? =
this as? FromChannelGroupContentMessage
@PreviewFeature
inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage =
this as FromChannelGroupContentMessage
@PreviewFeature
inline fun Message.whenGroupEventMessage(block: (GroupEventMessage) -> T) =
asGroupEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asGroupEventMessage(): GroupEventMessage? = this as? GroupEventMessage
@PreviewFeature
inline fun Message.requireGroupEventMessage(): GroupEventMessage = this as GroupEventMessage
@PreviewFeature
inline fun Message.whenPrivateEventMessage(block: (PrivateEventMessage) -> T) =
asPrivateEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asPrivateEventMessage(): PrivateEventMessage? =
this as? PrivateEventMessage
@PreviewFeature
inline fun Message.requirePrivateEventMessage(): PrivateEventMessage =
this as PrivateEventMessage
@PreviewFeature
inline fun Message.whenGroupContentMessage(block: (GroupContentMessage) -> T) =
asGroupContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asGroupContentMessage(): GroupContentMessage? =
this as? GroupContentMessage
@PreviewFeature
inline fun Message.requireGroupContentMessage(): GroupContentMessage =
this as GroupContentMessage
@PreviewFeature
inline fun Message.whenMediaGroupMessage(block: (MediaGroupMessage) -> T) =
asMediaGroupMessage()?.let(block)
@PreviewFeature
inline fun Message.asMediaGroupMessage(): MediaGroupMessage? =
this as? MediaGroupMessage
@PreviewFeature
inline fun Message.requireMediaGroupMessage(): MediaGroupMessage =
this as MediaGroupMessage
@PreviewFeature
inline fun Message.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) =
asPossiblyEditedMessage()?.let(block)
@PreviewFeature
inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage
@PreviewFeature
inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage
@PreviewFeature
inline fun Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) =
asPossiblyReplyMessage()?.let(block)
@PreviewFeature
inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage
@PreviewFeature
inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage
@PreviewFeature
inline fun Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) =
asPossiblyForwardedMessage()?.let(block)
@PreviewFeature
inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage
@PreviewFeature
inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage
@PreviewFeature
inline fun Message.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) =
asPossiblyPaymentMessage()?.let(block)
@PreviewFeature
inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage
@PreviewFeature
inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage
@PreviewFeature
inline fun Message.whenPrivateContentMessage(block: (PrivateContentMessage) -> T) =
asPrivateContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asPrivateContentMessage(): PrivateContentMessage? =
this as? PrivateContentMessage
@PreviewFeature
inline fun Message.requirePrivateContentMessage(): PrivateContentMessage =
this as PrivateContentMessage
@PreviewFeature
inline fun Message.whenPublicContentMessage(block: (PublicContentMessage) -> T) =
asPublicContentMessage()?.let(block)
@PreviewFeature
inline fun Message.asPublicContentMessage(): PublicContentMessage? =
this as? PublicContentMessage
@PreviewFeature
inline fun Message.requirePublicContentMessage(): PublicContentMessage =
this as PublicContentMessage
@PreviewFeature
inline fun Message.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block)
@PreviewFeature
inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage
@PreviewFeature
inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage
@PreviewFeature
inline fun Message.whenSupergroupEventMessage(block: (SupergroupEventMessage) -> T) =
asSupergroupEventMessage()?.let(block)
@PreviewFeature
inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage? =
this as? SupergroupEventMessage
@PreviewFeature
inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage =
this as SupergroupEventMessage
@PreviewFeature
inline fun Message.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block)
@PreviewFeature
inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType
@PreviewFeature
inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType
@PreviewFeature
inline fun Message.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage) -> T) =
asPossiblySentViaBotCommonMessage()?.let(block)
@PreviewFeature
inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage? =
this as? PossiblySentViaBotCommonMessage
@PreviewFeature
inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage =
this as PossiblySentViaBotCommonMessage
@PreviewFeature
inline fun Message.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block)
@PreviewFeature
inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage
@PreviewFeature
inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage
@PreviewFeature
inline fun BotAction.whenFindLocationAction(block: (FindLocationAction) -> T) = asFindLocationAction()?.let(block)
@PreviewFeature
inline fun BotAction.asFindLocationAction(): FindLocationAction? = this as? FindLocationAction
@PreviewFeature
inline fun BotAction.requireFindLocationAction(): FindLocationAction = this as FindLocationAction
@PreviewFeature
inline fun BotAction.whenRecordVoiceAction(block: (RecordVoiceAction) -> T) = asRecordVoiceAction()?.let(block)
@PreviewFeature
inline fun BotAction.asRecordVoiceAction(): RecordVoiceAction? = this as? RecordVoiceAction
@PreviewFeature
inline fun BotAction.requireRecordVoiceAction(): RecordVoiceAction = this as RecordVoiceAction
@PreviewFeature
inline fun BotAction.whenRecordVideoAction(block: (RecordVideoAction) -> T) = asRecordVideoAction()?.let(block)
@PreviewFeature
inline fun BotAction.asRecordVideoAction(): RecordVideoAction? = this as? RecordVideoAction
@PreviewFeature
inline fun BotAction.requireRecordVideoAction(): RecordVideoAction = this as RecordVideoAction
@PreviewFeature
inline fun BotAction.whenRecordVideoNoteAction(block: (RecordVideoNoteAction) -> T) =
asRecordVideoNoteAction()?.let(block)
@PreviewFeature
inline fun BotAction.asRecordVideoNoteAction(): RecordVideoNoteAction? = this as? RecordVideoNoteAction
@PreviewFeature
inline fun BotAction.requireRecordVideoNoteAction(): RecordVideoNoteAction = this as RecordVideoNoteAction
@PreviewFeature
inline fun BotAction.whenTypingAction(block: (TypingAction) -> T) = asTypingAction()?.let(block)
@PreviewFeature
inline fun BotAction.asTypingAction(): TypingAction? = this as? TypingAction
@PreviewFeature
inline fun BotAction.requireTypingAction(): TypingAction = this as TypingAction
@PreviewFeature
inline fun BotAction.whenChooseStickerAction(block: (ChooseStickerAction) -> T) =
asChooseStickerAction()?.let(block)
@PreviewFeature
inline fun BotAction.asChooseStickerAction(): ChooseStickerAction? = this as? ChooseStickerAction
@PreviewFeature
inline fun BotAction.requireChooseStickerAction(): ChooseStickerAction = this as ChooseStickerAction
@PreviewFeature
inline fun BotAction.whenUploadVoiceAction(block: (UploadVoiceAction) -> T) = asUploadVoiceAction()?.let(block)
@PreviewFeature
inline fun BotAction.asUploadVoiceAction(): UploadVoiceAction? = this as? UploadVoiceAction
@PreviewFeature
inline fun BotAction.requireUploadVoiceAction(): UploadVoiceAction = this as UploadVoiceAction
@PreviewFeature
inline fun BotAction.whenUploadDocumentAction(block: (UploadDocumentAction) -> T) =
asUploadDocumentAction()?.let(block)
@PreviewFeature
inline fun BotAction.asUploadDocumentAction(): UploadDocumentAction? = this as? UploadDocumentAction
@PreviewFeature
inline fun BotAction.requireUploadDocumentAction(): UploadDocumentAction = this as UploadDocumentAction
@PreviewFeature
inline fun BotAction.whenUploadPhotoAction(block: (UploadPhotoAction) -> T) = asUploadPhotoAction()?.let(block)
@PreviewFeature
inline fun BotAction.asUploadPhotoAction(): UploadPhotoAction? = this as? UploadPhotoAction
@PreviewFeature
inline fun BotAction.requireUploadPhotoAction(): UploadPhotoAction = this as UploadPhotoAction
@PreviewFeature
inline fun BotAction.whenUploadVideoAction(block: (UploadVideoAction) -> T) = asUploadVideoAction()?.let(block)
@PreviewFeature
inline fun BotAction.asUploadVideoAction(): UploadVideoAction? = this as? UploadVideoAction
@PreviewFeature
inline fun BotAction.requireUploadVideoAction(): UploadVideoAction = this as UploadVideoAction
@PreviewFeature
inline fun BotAction.whenUploadVideoNoteAction(block: (UploadVideoNoteAction) -> T) =
asUploadVideoNoteAction()?.let(block)
@PreviewFeature
inline fun BotAction.asUploadVideoNoteAction(): UploadVideoNoteAction? = this as? UploadVideoNoteAction
@PreviewFeature
inline fun BotAction.requireUploadVideoNoteAction(): UploadVideoNoteAction = this as UploadVideoNoteAction
@PreviewFeature
inline fun InlineQuery.whenBaseInlineQuery(block: (BaseInlineQuery) -> T) = asBaseInlineQuery()?.let(block)
@PreviewFeature
inline fun InlineQuery.asBaseInlineQuery(): BaseInlineQuery? =
this as? BaseInlineQuery
@PreviewFeature
inline fun InlineQuery.requireBaseInlineQuery(): BaseInlineQuery =
this as BaseInlineQuery
@PreviewFeature
inline fun InlineQuery.whenLocationInlineQuery(block: (LocationInlineQuery) -> T) =
asLocationInlineQuery()?.let(block)
@PreviewFeature
inline fun InlineQuery.asLocationInlineQuery(): LocationInlineQuery? =
this as? LocationInlineQuery
@PreviewFeature
inline fun InlineQuery.requireLocationInlineQuery(): LocationInlineQuery =
this as LocationInlineQuery
@PreviewFeature
inline fun InputMessageContent.whenInputContactMessageContent(block: (InputContactMessageContent) -> T) =
asInputContactMessageContent()?.let(block)
@PreviewFeature
inline fun InputMessageContent.asInputContactMessageContent(): InputContactMessageContent? =
this as? InputContactMessageContent
@PreviewFeature
inline fun InputMessageContent.requireInputContactMessageContent(): InputContactMessageContent =
this as InputContactMessageContent
@PreviewFeature
inline fun InputMessageContent.whenInputLocationMessageContent(block: (InputLocationMessageContent) -> T) =
asInputLocationMessageContent()?.let(block)
@PreviewFeature
inline fun InputMessageContent.asInputLocationMessageContent(): InputLocationMessageContent? =
this as? InputLocationMessageContent
@PreviewFeature
inline fun InputMessageContent.requireInputLocationMessageContent(): InputLocationMessageContent =
this as InputLocationMessageContent
@PreviewFeature
inline fun InputMessageContent.whenInputTextMessageContent(block: (InputTextMessageContent) -> T) =
asInputTextMessageContent()?.let(block)
@PreviewFeature
inline fun InputMessageContent.asInputTextMessageContent(): InputTextMessageContent? = this as? InputTextMessageContent
@PreviewFeature
inline fun InputMessageContent.requireInputTextMessageContent(): InputTextMessageContent =
this as InputTextMessageContent
@PreviewFeature
inline fun InputMessageContent.whenInputVenueMessageContent(block: (InputVenueMessageContent) -> T) =
asInputVenueMessageContent()?.let(block)
@PreviewFeature
inline fun InputMessageContent.asInputVenueMessageContent(): InputVenueMessageContent? =
this as? InputVenueMessageContent
@PreviewFeature
inline fun InputMessageContent.requireInputVenueMessageContent(): InputVenueMessageContent =
this as InputVenueMessageContent
@PreviewFeature
inline fun