source: timeline/src/main/java/geniusweb/deadline/DeadlineRounds.java@ 16

Last change on this file since 16 was 1, checked in by bart, 5 years ago

Initial Release

File size: 1.7 KB
RevLine 
[1]1package geniusweb.deadline;
2
3import com.fasterxml.jackson.annotation.JsonCreator;
4import com.fasterxml.jackson.annotation.JsonProperty;
5import com.fasterxml.jackson.annotation.JsonTypeName;
6
7/**
8 * The number of rounds that a session will be allowed to run. This extends
9 * DeadlineTime because a rounds deadline is an ADDITIONAL deadline on top of a
10 * normal time deadline. It is not hard defined what a round is, this is up to
11 * the protocol.
12 */
13@JsonTypeName("deadlinerounds")
14public class DeadlineRounds extends DeadlineTime {
15 private final Integer rounds;
16
17 /**
18 *
19 * @param rounds the max number of rounds for the session
20 * @param durationms the maximum time in milliseconds the session is allowed
21 * to run.
22 */
23 @JsonCreator
24 public DeadlineRounds(@JsonProperty("rounds") Integer rounds,
25 @JsonProperty("durationms") long durationms) {
26 super(durationms);
27 if (rounds <= 0) {
28 throw new IllegalArgumentException(
29 "deadline must have at least 1 round");
30 }
31 this.rounds = rounds;
32 }
33
34 public Integer getRounds() {
35 return rounds;
36 }
37
38 @Override
39 public int hashCode() {
40 final int prime = 31;
41 int result = super.hashCode();
42 result = prime * result + ((rounds == null) ? 0 : rounds.hashCode());
43 return result;
44 }
45
46 @Override
47 public boolean equals(Object obj) {
48 if (this == obj)
49 return true;
50 if (!super.equals(obj))
51 return false;
52 if (getClass() != obj.getClass())
53 return false;
54 DeadlineRounds other = (DeadlineRounds) obj;
55 if (rounds == null) {
56 if (other.rounds != null)
57 return false;
58 } else if (!rounds.equals(other.rounds))
59 return false;
60 return true;
61 }
62
63 @Override
64 public String toString() {
65 return "DeadlineRounds[" + rounds + "," + getDuration() + "]";
66 }
67}
Note: See TracBrowser for help on using the repository browser.