2019-04-08 02:43:46 +02:00
package org.telegram.telegrambots.meta.api.objects.polls ;
import com.fasterxml.jackson.annotation.JsonProperty ;
import org.telegram.telegrambots.meta.api.interfaces.BotApiObject ;
2020-04-24 10:03:23 +02:00
import org.telegram.telegrambots.meta.api.objects.MessageEntity ;
2019-04-08 02:43:46 +02:00
import java.util.List ;
2020-01-24 00:23:29 +01:00
import java.util.Objects ;
2019-04-08 02:43:46 +02:00
/ * *
* @author Ruben Bermudez
* @version 4 . 2
*
* This object contains information about a poll .
* /
public class Poll implements BotApiObject {
private static final String ID_FIELD = " id " ;
private static final String QUESTION_FIELD = " question " ;
private static final String OPTIONS_FIELD = " options " ;
2020-01-24 00:23:29 +01:00
private static final String TOTALVOTERCOUNT_FIELD = " total_voter_count " ;
2019-04-08 02:43:46 +02:00
private static final String ISCLOSED_FIELD = " is_closed " ;
2020-01-24 00:23:29 +01:00
private static final String ISANONYMOUS_FIELD = " is_anonymous " ;
private static final String TYPE_FIELD = " type " ;
private static final String ALLOWSMULTIPLEANSWERS_FIELD = " allows_multiple_answers " ;
private static final String CORRECTOPTIONID_FIELD = " correct_option_id " ;
2020-04-24 10:03:23 +02:00
private static final String OPENPERIOD_FIELD = " open_period " ;
private static final String CLOSEDATE_FIELD = " close_date " ;
private static final String EXPLANATION_FIELD = " explanation " ;
private static final String EXPLANATIONENTITIES_FIELD = " explanation_entities " ;
2019-04-08 02:43:46 +02:00
@JsonProperty ( ID_FIELD )
private String id ; ///< Unique poll identifier
@JsonProperty ( QUESTION_FIELD )
private String question ; ///< Poll question, 1-255 characters
@JsonProperty ( OPTIONS_FIELD )
private List < PollOption > options ; ///< List of poll options
2020-01-24 00:23:29 +01:00
@JsonProperty ( TOTALVOTERCOUNT_FIELD )
private Integer totalVoterCount ; ///< Total number of users that voted in the poll
2019-04-08 02:43:46 +02:00
@JsonProperty ( ISCLOSED_FIELD )
private Boolean isClosed ; ///< True, if the poll is closed
2020-01-24 00:23:29 +01:00
@JsonProperty ( ISANONYMOUS_FIELD )
private Boolean isAnonymous ; ///< True, if the poll is closed
@JsonProperty ( TYPE_FIELD )
private String type ; ///< Poll type, currently can be “regular” or “quiz”
@JsonProperty ( ALLOWSMULTIPLEANSWERS_FIELD )
private Boolean allowMultipleAnswers ; ///< True, if the poll allows multiple answers
/ * *
* Optional . 0 - based identifier of the correct answer option .
*
* @apiNote Available only for polls in the quiz mode ,
* which are closed or was sent ( not forwarded ) to the private chat with the bot .
* /
@JsonProperty ( CORRECTOPTIONID_FIELD )
private Integer correctOptionId ; ///< True, if the poll allows multiple answers
2020-04-24 10:03:23 +02:00
@JsonProperty ( OPENPERIOD_FIELD )
private Integer openPeriod ; ///< Optional. Amount of time in seconds the poll will be active after creation
@JsonProperty ( CLOSEDATE_FIELD )
private Integer closeDate ; ///< Optional. Point in time (Unix timestamp) when the poll will be automatically closed
@JsonProperty ( EXPLANATION_FIELD )
private String explanation ; ///< Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters
@JsonProperty ( EXPLANATIONENTITIES_FIELD )
private List < MessageEntity > explanationEntities ; ///< Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation
2019-04-08 02:43:46 +02:00
public Poll ( ) {
}
public String getId ( ) {
return id ;
}
public void setId ( String id ) {
this . id = id ;
}
public String getQuestion ( ) {
return question ;
}
public void setQuestion ( String question ) {
this . question = question ;
}
public List < PollOption > getOptions ( ) {
return options ;
}
public void setOptions ( List < PollOption > options ) {
this . options = options ;
}
public Boolean getClosed ( ) {
return isClosed ;
}
public void setClosed ( Boolean closed ) {
isClosed = closed ;
}
2020-01-24 00:23:29 +01:00
public Integer getTotalVoterCount ( ) {
return totalVoterCount ;
}
public void setTotalVoterCount ( Integer totalVoterCount ) {
this . totalVoterCount = totalVoterCount ;
}
public Boolean getAnonymous ( ) {
return isAnonymous ;
}
public void setAnonymous ( Boolean anonymous ) {
isAnonymous = anonymous ;
}
public String getType ( ) {
return type ;
}
public void setType ( String type ) {
this . type = type ;
}
public Boolean getAllowMultipleAnswers ( ) {
return allowMultipleAnswers ;
}
public void setAllowMultipleAnswers ( Boolean allowMultipleAnswers ) {
this . allowMultipleAnswers = allowMultipleAnswers ;
}
public Integer getCorrectOptionId ( ) {
return correctOptionId ;
}
public void setCorrectOptionId ( Integer correctOptionId ) {
this . correctOptionId = correctOptionId ;
}
2020-04-24 10:03:23 +02:00
public Integer getOpenPeriod ( ) {
return openPeriod ;
}
public Integer getCloseDate ( ) {
return closeDate ;
}
public String getExplanation ( ) {
return explanation ;
}
public List < MessageEntity > getExplanationEntities ( ) {
return explanationEntities ;
}
2020-01-24 00:23:29 +01:00
@Override
public boolean equals ( Object o ) {
if ( this = = o ) return true ;
if ( ! ( o instanceof Poll ) ) return false ;
Poll poll = ( Poll ) o ;
return Objects . equals ( id , poll . id ) & &
Objects . equals ( question , poll . question ) & &
Objects . equals ( options , poll . options ) & &
Objects . equals ( totalVoterCount , poll . totalVoterCount ) & &
Objects . equals ( isClosed , poll . isClosed ) & &
Objects . equals ( isAnonymous , poll . isAnonymous ) & &
Objects . equals ( type , poll . type ) & &
Objects . equals ( allowMultipleAnswers , poll . allowMultipleAnswers ) & &
2020-04-24 10:03:23 +02:00
Objects . equals ( correctOptionId , poll . correctOptionId ) & &
Objects . equals ( openPeriod , poll . openPeriod ) & &
Objects . equals ( closeDate , poll . closeDate ) & &
Objects . equals ( explanation , poll . explanation ) & &
Objects . equals ( explanationEntities , poll . explanationEntities ) ;
2020-01-24 00:23:29 +01:00
}
@Override
public int hashCode ( ) {
2020-04-24 10:03:23 +02:00
return Objects . hash ( id , question , options , totalVoterCount , isClosed , isAnonymous , type , allowMultipleAnswers , correctOptionId , openPeriod , closeDate , explanation , explanationEntities ) ;
2020-01-24 00:23:29 +01:00
}
2019-04-08 02:43:46 +02:00
@Override
public String toString ( ) {
return " Poll{ " +
" id=' " + id + '\'' +
" , question=' " + question + '\'' +
" , options= " + options +
2020-01-24 00:23:29 +01:00
" , totalVoterCount= " + totalVoterCount +
2019-04-08 02:43:46 +02:00
" , isClosed= " + isClosed +
2020-01-24 00:23:29 +01:00
" , isAnonymous= " + isAnonymous +
" , type=' " + type + '\'' +
" , allowMultipleAnswers= " + allowMultipleAnswers +
" , correctOptionId= " + correctOptionId +
2020-04-24 10:03:23 +02:00
" , openPeriod= " + openPeriod +
" , closeDate= " + closeDate +
" , explanation=' " + explanation + '\'' +
" , explanationEntities= " + explanationEntities +
2019-04-08 02:43:46 +02:00
'}' ;
}
}