source: events/src/main/java/geniusweb/actions/Comparison.java@ 17

Last change on this file since 17 was 10, checked in by bart, 5 years ago

Update 28 jan 2020

File size: 2.2 KB
RevLine 
[10]1package geniusweb.actions;
2
3import java.util.List;
4
5import com.fasterxml.jackson.annotation.JsonCreator;
6import com.fasterxml.jackson.annotation.JsonProperty;
7
8import geniusweb.issuevalue.Bid;
9
10/**
11 * A statement from a Party that some bids are better and worse than
12 * {@link #getBid()} bid. Typically this is a response to a CompareWithBid
13 * inform
14 *
15 */
16public class Comparison extends ActionWithBid {
17
18 private List<Bid> better;
19 private List<Bid> worse;
20
21 /**
22 * @param id the party id that made this comparison
23 * @param bid the bid that is compared wiht
24 * @param better list of bids that are better than bid
25 * @param worse list of bids that are worse than bid
26 */
27 @JsonCreator
28 public Comparison(@JsonProperty("id") PartyId id,
29 @JsonProperty("bid") Bid bid,
30 @JsonProperty("better") List<Bid> better,
31 @JsonProperty("worse") List<Bid> worse) {
32 super(id, bid);
33 if (bid == null || better == null || worse == null)
34 throw new IllegalArgumentException(
35 "bid, better and worse must not be null");
36 this.better = better;
37 this.worse = worse;
38 }
39
40 /**
41 * @return All bids that are better than the bid. Maybe empty
42 *
43 */
44 public List<Bid> getBetter() {
45 return better;
46 }
47
48 /**
49 * @return All bids that are worse than the bid. Maybe empty
50 *
51 */
52
53 public List<Bid> getWorse() {
54 return worse;
55 }
56
57 @Override
58 public String toString() {
59 return "Comparison[" + getActor() + "," + getBid() + ",better=" + better
60 + ",worse=" + worse + "]";
61 }
62
63 @Override
64 public int hashCode() {
65 final int prime = 31;
66 int result = super.hashCode();
67 result = prime * result + ((better == null) ? 0 : better.hashCode());
68 result = prime * result + ((worse == null) ? 0 : worse.hashCode());
69 return result;
70 }
71
72 @Override
73 public boolean equals(Object obj) {
74 if (this == obj)
75 return true;
76 if (!super.equals(obj))
77 return false;
78 if (getClass() != obj.getClass())
79 return false;
80 Comparison other = (Comparison) obj;
81 if (better == null) {
82 if (other.better != null)
83 return false;
84 } else if (!better.equals(other.better))
85 return false;
86 if (worse == null) {
87 if (other.worse != null)
88 return false;
89 } else if (!worse.equals(other.worse))
90 return false;
91 return true;
92 }
93
94}
Note: See TracBrowser for help on using the repository browser.