Changeset 22 for events/src/main/java
- Timestamp:
- 09/22/20 16:26:36 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
events/src/main/java/geniusweb/actions/Vote.java
r21 r22 14 14 public class Vote extends ActionWithBid { 15 15 private final Integer minPower; 16 private final Integer maxPower; 16 17 17 18 /** … … 19 20 * @param bid the bid that is voted on 20 21 * @param minPower the minimum power this bid must get in order for the vote 21 * to be valid. If power=1 for all participants (usually the 22 * default) power can be interpreted as number of votes 22 * to be valid. Power is the sum of the powers of the 23 * parties that are in the deal. If power=1 for all 24 * participants (usually the default) power can be 25 * interpreted as number of votes 26 * @param maxPower the maximum power this bid must get in order for the vote 27 * to be valid. See {@link #minPower} 23 28 */ 24 29 @JsonCreator 25 30 public Vote(@JsonProperty("actor") PartyId id, @JsonProperty("bid") Bid bid, 26 @JsonProperty("minPower") Integer minPower) { 31 @JsonProperty("minPower") Integer minPower, 32 @JsonProperty("maxPower") Integer maxPower) { 27 33 super(id, bid); 28 34 this.minPower = minPower; 29 if (bid == null || minPower == null || minPower < 1) { 35 this.maxPower = maxPower; 36 if (bid == null || minPower == null || minPower < 1 || maxPower == null 37 || maxPower < minPower) { 30 38 throw new IllegalArgumentException( 31 "Vote must have non-null bid and minVotes, and min Votes must be >=1");39 "Vote must have non-null bid and minVotes, and minPower must be >=1 and maxPower must be >=minPower"); 32 40 } 33 41 } … … 35 43 /** 36 44 * 37 * @return the minimum number of votes this bid must get in order for the38 * v ote to be valid.45 * @return the minimum power this bid must get in order for the vote to be 46 * valid. 39 47 */ 40 48 public Integer getMinPower() { … … 42 50 } 43 51 52 /** 53 * 54 * @return the max power this bid must get in order for the vote to be 55 * valid. 56 */ 57 58 public Integer getMaxPower() { 59 return maxPower; 60 } 61 44 62 @Override 45 63 public String toString() { 46 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "]"; 64 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "," 65 + maxPower + "]"; 47 66 } 48 67 … … 51 70 final int prime = 31; 52 71 int result = super.hashCode(); 72 result = prime * result 73 + ((maxPower == null) ? 0 : maxPower.hashCode()); 53 74 result = prime * result 54 75 + ((minPower == null) ? 0 : minPower.hashCode()); … … 65 86 return false; 66 87 Vote other = (Vote) obj; 88 if (maxPower == null) { 89 if (other.maxPower != null) 90 return false; 91 } else if (!maxPower.equals(other.maxPower)) 92 return false; 67 93 if (minPower == null) { 68 94 if (other.minPower != null)
Note:
See TracChangeset
for help on using the changeset viewer.