Class PollCreationMessage

java.lang.Object
it.auties.whatsapp.model.message.standard.PollCreationMessage
All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage, it.auties.protobuf.model.ProtobufObject, ContextualMessage, Message

public final class PollCreationMessage extends Object implements ContextualMessage
A model class that represents a message holding a poll inside
  • Field Details

    • encryptionKey

      private byte[] encryptionKey
    • title

      private final String title
    • selectableOptions

      private final List<PollOption> selectableOptions
    • selectableOptionsCount

      private final int selectableOptionsCount
    • contextInfo

      private final ContextInfo contextInfo
    • selectableOptionsMap

      private final Map<String,PollOption> selectableOptionsMap
    • selectedOptionsMap

      private final Map<Jid,Collection<PollOption>> selectedOptionsMap
  • Constructor Details

  • Method Details

    • simpleBuilder

      static PollCreationMessage simpleBuilder(String title, List<PollOption> selectableOptions)
      Constructs a new builder to create a PollCreationMessage The newsletters can be later sent using Whatsapp.sendMessage(ChatMessageInfo)
      Parameters:
      title - the non-null title of the poll
      selectableOptions - the null-null non-empty options of the poll
      Returns:
      a non-null new message
    • getSelectedOptions

      public Collection<PollOption> getSelectedOptions(JidProvider voter)
      Returns an unmodifiable list of the options that a contact voted in this poll
      Parameters:
      voter - the non-null contact that voted in this poll
      Returns:
      a non-null unmodifiable map
    • addSelectedOptions

      public void addSelectedOptions(JidProvider voter, Collection<PollOption> voted)
    • addSelectableOption

      public void addSelectableOption(String hash, PollOption option)
    • getSelectableOption

      public Optional<PollOption> getSelectableOption(String hash)
    • type

      public MessageType type()
      Description copied from interface: Message
      Return message type
      Specified by:
      type in interface Message
      Returns:
      a non-null message type
    • category

      public MessageCategory category()
      Description copied from interface: Message
      Return message category
      Specified by:
      category in interface Message
      Returns:
      a non-null message category
    • title

      public String title()
    • selectableOptions

      public List<PollOption> selectableOptions()
    • selectableOptionsCount

      public int selectableOptionsCount()
    • encryptionKey

      public Optional<byte[]> encryptionKey()
    • setEncryptionKey

      public void setEncryptionKey(byte[] encryptionKey)
    • contextInfo

      public Optional<ContextInfo> contextInfo()
      Specified by:
      contextInfo in interface ContextualMessage