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

Last change on this file since 29 was 29, checked in by bart, 3 years ago

some minor fixes

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.Offer;
11import geniusweb.actions.PartyId;
12
13/**
14 * Informs a party that it's time to do voting.
15 */
16public class Voting implements Inform {
17
18 private final List<Offer> offers;
19 private final Map<PartyId, Integer> powers;
20
21 @JsonCreator
22 public Voting(@JsonProperty("offers") List<Offer> offers,
23 @JsonProperty("powers") Map<PartyId, Integer> powers) {
24 this.offers = offers;
25 this.powers = powers;
26 }
27
28 /**
29 * @return list of bids to be voted on
30 */
31 public List<Offer> getBids() {
32 return Collections.unmodifiableList(offers);
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 + ((offers == null) ? 0 : offers.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 (offers == null) {
64 if (other.offers != null)
65 return false;
66 } else if (!offers.equals(other.offers))
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[" + offers + "," + powers + "]";
79 }
80
81}
Note: See TracBrowser for help on using the repository browser.