package geniusweb.inform; import java.util.Collections; import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import geniusweb.actions.Offer; import geniusweb.actions.PartyId; /** * Informs a party that it's time to do voting. */ public class Voting implements Inform { private final List offers; private final Map powers; @JsonCreator public Voting(@JsonProperty("offers") List offers, @JsonProperty("powers") Map powers) { this.offers = offers; this.powers = powers; } /** * @return list of bids to be voted on */ public List getBids() { return Collections.unmodifiableList(offers); } /** * * @return map with the power of each party in the negotiation. This map may * contain parties that are already finished, eg they reached an * agreement or walked away. */ public Map getPowers() { return Collections.unmodifiableMap(powers); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((offers == null) ? 0 : offers.hashCode()); result = prime * result + ((powers == null) ? 0 : powers.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Voting other = (Voting) obj; if (offers == null) { if (other.offers != null) return false; } else if (!offers.equals(other.offers)) return false; if (powers == null) { if (other.powers != null) return false; } else if (!powers.equals(other.powers)) return false; return true; } @Override public String toString() { return "Voting[" + offers + "," + powers + "]"; } }