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

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

Fixed windows time-out.

File size: 1.9 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 offers to be voted on
30 */
31 public List<Offer> getOffers() {
32 return Collections.unmodifiableList(offers);
33 }
34
35 @Deprecated
36 public List<Offer> getBids() {
37 return getOffers();
38 }
39
40 /**
41 *
42 * @return map with the power of each party in the negotiation. This map may
43 * contain parties that are already finished, eg they reached an
44 * agreement or walked away.
45 */
46 public Map<PartyId, Integer> getPowers() {
47 return Collections.unmodifiableMap(powers);
48 }
49
50 @Override
51 public int hashCode() {
52 final int prime = 31;
53 int result = 1;
54 result = prime * result + ((offers == null) ? 0 : offers.hashCode());
55 result = prime * result + ((powers == null) ? 0 : powers.hashCode());
56 return result;
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj)
62 return true;
63 if (obj == null)
64 return false;
65 if (getClass() != obj.getClass())
66 return false;
67 Voting other = (Voting) obj;
68 if (offers == null) {
69 if (other.offers != null)
70 return false;
71 } else if (!offers.equals(other.offers))
72 return false;
73 if (powers == null) {
74 if (other.powers != null)
75 return false;
76 } else if (!powers.equals(other.powers))
77 return false;
78 return true;
79 }
80
81 @Override
82 public String toString() {
83 return "Voting[" + offers + "," + powers + "]";
84 }
85
86}
Note: See TracBrowser for help on using the repository browser.