source: events/src/main/java/geniusweb/actions/ElicitComparison.java@ 53

Last change on this file since 53 was 52, checked in by ruud, 21 months ago

Fixed small issues in domaineditor.

File size: 2.0 KB
RevLine 
[52]1package geniusweb.actions;
2
3import java.util.Collections;
4import java.util.LinkedList;
5import java.util.List;
6
7import com.fasterxml.jackson.annotation.JsonCreator;
8import com.fasterxml.jackson.annotation.JsonProperty;
9
10import geniusweb.issuevalue.Bid;
11
12/**
13 * Request a comparison from the cob party. The party can do a
14 * {@link Comparison} action as a response.
15 */
16public class ElicitComparison extends ActionWithBid {
17 private final List<Bid> options = new LinkedList<>();
18
19 /**
20 * @param id the eliciting party.
21 * @param bid the bid to compare the options with
22 * @param opts the available options that may be chosen from. Must not be
23 * null and must have at least 2 options.
24 */
25 @JsonCreator
26 public ElicitComparison(@JsonProperty("actor") PartyId id,
27 @JsonProperty("bid") Bid bid,
28 @JsonProperty("options") List<Bid> opts) {
29 super(id, bid);
30 if (bid == null)
31 throw new IllegalArgumentException(
32 "Bid to compare with must not be null");
33 if (opts == null || opts.size() < 1) {
34 throw new IllegalArgumentException(
35 "opts must not be null and have at least 1 option");
36 }
37 this.options.addAll(opts);
38 }
39
40 /**
41 *
42 * @return the list of {@link Bid}s to compare {@link #getBid()} with
43 */
44 public List<Bid> getOptions() {
45 return Collections.unmodifiableList(options);
46 }
47
48 @Override
49 public int hashCode() {
50 final int prime = 31;
51 int result = super.hashCode();
52 result = prime * result + ((options == null) ? 0 : options.hashCode());
53 return result;
54 }
55
56 @Override
57 public boolean equals(Object obj) {
58 if (this == obj)
59 return true;
60 if (!super.equals(obj))
61 return false;
62 if (getClass() != obj.getClass())
63 return false;
64 ElicitComparison other = (ElicitComparison) obj;
65 if (options == null) {
66 if (other.options != null)
67 return false;
68 } else if (!options.equals(other.options))
69 return false;
70 return true;
71 }
72
73 @Override
74 public String toString() {
75 return "ElicitComparison[" + getActor() + "," + getBid() + "," + options
76 + "]";
77
78 }
79
80}
Note: See TracBrowser for help on using the repository browser.