source: events/src/main/java/geniusweb/inform/Voting.java@ 22

Last change on this file since 22 was 21, checked in by bart, 4 years ago

Version 1.5.

File size: 1.8 KB
Line 
1package geniusweb.inform;
2
3import java.util.Collections;
4import java.util.List;
5import java.util.Map;
6
7import com.fasterxml.jackson.annotation.JsonCreator;
8import com.fasterxml.jackson.annotation.JsonProperty;
9
10import geniusweb.actions.PartyId;
11import geniusweb.issuevalue.Bid;
12
13/**
14 * Informs a party that it's time to do voting.
15 */
16public class Voting implements Inform {
17
18 private final List<Bid> bids;
19 private final Map<PartyId, Integer> powers;
20
21 @JsonCreator
22 public Voting(@JsonProperty("bids") List<Bid> bids,
23 @JsonProperty("powers") Map<PartyId, Integer> powers) {
24 this.bids = bids;
25 this.powers = powers;
26 }
27
28 /**
29 * @return list of bids to be voted on
30 */
31 public List<Bid> getBids() {
32 return Collections.unmodifiableList(bids);
33 }
34
35 /**
36 *
37 * @return map with the power of each party in the negotiation. This map may
38 * contain parties that are already finished, eg they reached an
39 * agreement or walked away.
40 */
41 public Map<PartyId, Integer> getPowers() {
42 return Collections.unmodifiableMap(powers);
43 }
44
45 @Override
46 public int hashCode() {
47 final int prime = 31;
48 int result = 1;
49 result = prime * result + ((bids == null) ? 0 : bids.hashCode());
50 result = prime * result + ((powers == null) ? 0 : powers.hashCode());
51 return result;
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj)
57 return true;
58 if (obj == null)
59 return false;
60 if (getClass() != obj.getClass())
61 return false;
62 Voting other = (Voting) obj;
63 if (bids == null) {
64 if (other.bids != null)
65 return false;
66 } else if (!bids.equals(other.bids))
67 return false;
68 if (powers == null) {
69 if (other.powers != null)
70 return false;
71 } else if (!powers.equals(other.powers))
72 return false;
73 return true;
74 }
75
76 @Override
77 public String toString() {
78 return "Voting[" + bids + "," + powers + "]";
79 }
80
81}
Note: See TracBrowser for help on using the repository browser.