package geniusweb.deadline; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeName; /** * The number of rounds that a session will be allowed to run. This extends * DeadlineTime because a rounds deadline is an ADDITIONAL deadline on top of a * normal time deadline. It is not hard defined what a round is, this is up to * the protocol. */ @JsonTypeName("deadlinerounds") public class DeadlineRounds extends DeadlineTime { private final Integer rounds; /** * * @param rounds the max number of rounds for the session * @param durationms the maximum time in milliseconds the session is allowed * to run. */ @JsonCreator public DeadlineRounds(@JsonProperty("rounds") Integer rounds, @JsonProperty("durationms") long durationms) { super(durationms); if (rounds <= 0) { throw new IllegalArgumentException( "deadline must have at least 1 round"); } this.rounds = rounds; } public Integer getRounds() { return rounds; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((rounds == null) ? 0 : rounds.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; DeadlineRounds other = (DeadlineRounds) obj; if (rounds == null) { if (other.rounds != null) return false; } else if (!rounds.equals(other.rounds)) return false; return true; } @Override public String toString() { return "DeadlineRounds[" + rounds + "," + getDuration() + "]"; } }