package geniusweb.actions; import java.util.Collections; import java.util.LinkedList; import java.util.List; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import geniusweb.issuevalue.Bid; /** * Request a comparison from the cob party. The party can do a * {@link Comparison} action as a response. */ public class ElicitComparison extends ActionWithBid { private final List options = new LinkedList<>(); /** * @param id the eliciting party. * @param bid the bid to compare the options with * @param opts the available options that may be chosen from. Must not be * null and must have at least 2 options. */ @JsonCreator public ElicitComparison(@JsonProperty("actor") PartyId id, @JsonProperty("bid") Bid bid, @JsonProperty("options") List opts) { super(id, bid); if (bid == null) throw new IllegalArgumentException( "Bid to compare with must not be null"); if (opts == null || opts.size() < 1) { throw new IllegalArgumentException( "opts must not be null and have at least 1 option"); } this.options.addAll(opts); } /** * * @return the list of {@link Bid}s to compare {@link #getBid()} with */ public List getOptions() { return Collections.unmodifiableList(options); } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((options == null) ? 0 : options.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ElicitComparison other = (ElicitComparison) obj; if (options == null) { if (other.options != null) return false; } else if (!options.equals(other.options)) return false; return true; } @Override public String toString() { return "ElicitComparison[" + getActor() + "," + getBid() + "," + options + "]"; } }