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

Last change on this file since 53 was 52, checked in by ruud, 22 months ago

Fixed small issues in domaineditor.

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