Changeset 22 for events/src/main/java


Ignore:
Timestamp:
09/22/20 16:26:36 (4 years ago)
Author:
bart
Message:

Minor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • events/src/main/java/geniusweb/actions/Vote.java

    r21 r22  
    1414public class Vote extends ActionWithBid {
    1515        private final Integer minPower;
     16        private final Integer maxPower;
    1617
    1718        /**
     
    1920         * @param bid      the bid that is voted on
    2021         * @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}
    2328         */
    2429        @JsonCreator
    2530        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) {
    2733                super(id, bid);
    2834                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) {
    3038                        throw new IllegalArgumentException(
    31                                         "Vote must have non-null bid and minVotes, and minVotes must be >=1");
     39                                        "Vote must have non-null bid and minVotes, and minPower must be >=1 and maxPower must be >=minPower");
    3240                }
    3341        }
     
    3543        /**
    3644         *
    37          * @return the minimum number of votes this bid must get in order for the
    38          *         vote to be valid.
     45         * @return the minimum power this bid must get in order for the vote to be
     46         *         valid.
    3947         */
    4048        public Integer getMinPower() {
     
    4250        }
    4351
     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
    4462        @Override
    4563        public String toString() {
    46                 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "]";
     64                return "Vote[" + getActor() + "," + getBid() + "," + minPower + ","
     65                                + maxPower + "]";
    4766        }
    4867
     
    5170                final int prime = 31;
    5271                int result = super.hashCode();
     72                result = prime * result
     73                                + ((maxPower == null) ? 0 : maxPower.hashCode());
    5374                result = prime * result
    5475                                + ((minPower == null) ? 0 : minPower.hashCode());
     
    6586                        return false;
    6687                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;
    6793                if (minPower == null) {
    6894                        if (other.minPower != null)
Note: See TracChangeset for help on using the changeset viewer.