Interface ApiMethodMultiResponse

All Superinterfaces:
ApiMethod<Serializable>
All Known Implementing Classes:
EditMessageCaption, EditMessageLiveLocation, EditMessageReplyMarkup, EditMessageText, SetGameScore, StopMessageLiveLocation

public interface ApiMethodMultiResponse extends ApiMethod<Serializable>
Base API method that supports requests with multiple response types
  • Method Details

    • getSerializableClasses

      @NotNull @NotNull List<Class<? extends Serializable>> getSerializableClasses()
      Retrieves the list of classes representing possible types for deserialization of the response.
      Returns:
      A List of classes extending Serializable.
    • deserializeResponse

      @NotNull default @NotNull Serializable deserializeResponse(@NotNull @NotNull String answer) throws TelegramRequestException
      Deserializes the response from a string answer.
      Specified by:
      deserializeResponse in interface ApiMethod<Serializable>
      Parameters:
      answer - The string representing the response.
      Returns:
      The deserialized response object.
      Throws:
      TelegramRequestException - If an error occurs during deserialization.
    • deserializeResponse

      default Serializable deserializeResponse(String answer, List<Class<? extends Serializable>> possibleValues) throws TelegramRequestException
      Deserializes the response from a string answer using a list of possible classes.
      Parameters:
      answer - The string representing the response.
      possibleValues - The list of possible classes for deserialization.
      Returns:
      The deserialized response object. Null if an error occurs during deserialization.
      Throws:
      TelegramRequestException - If an error occurs during deserialization.