package geniusweb.inform; import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import geniusweb.actions.PartyId; import geniusweb.progress.Progress; import geniusweb.references.Parameters; import geniusweb.references.ProfileRef; import geniusweb.references.ProtocolRef; /** * Informs a Party about all settings for the upcoming negotiation session. This * should be sent to a party one time, so that the party knows the situation. * */ public class Settings implements Inform { private ProfileRef profile; private ProtocolRef protocol; private Progress progress; private PartyId id; private Parameters parameters; /** * * @param id the {@link PartyId} for this party * @param profile the profile used for this party in this session * @param protocol the protocol used in this session * @param progress the {@link Progress} object used for this session * @param parameters a {@link Map} <String, Object> containing * initialization parameters for this party. The Object * can be a HashMap, ArrayList, String, or number * (Integer, Double, etc). The Object should not be just * any Object because deserialization will work only with * the mentioned types. */ @JsonCreator public Settings(@JsonProperty("id") PartyId id, @JsonProperty("profile") ProfileRef profile, @JsonProperty("protocol") ProtocolRef protocol, @JsonProperty("progress") Progress progress, @JsonProperty("parameters") Parameters parameters) { if (profile == null || protocol == null || progress == null || parameters == null) { throw new IllegalArgumentException( "party, profile, protocol, parameters and progress must be not null."); } this.profile = profile; this.protocol = protocol; this.progress = progress; this.parameters = parameters; this.id = id; } /** * * @return the profile used for this party in this session */ public ProfileRef getProfile() { return profile; } public ProtocolRef getProtocol() { return protocol; } /** * * @return the {@link Progress} object used for this session */ public Progress getProgress() { return progress; } /** * @return the party ID of this party */ public PartyId getID() { return id; } /** * * @return a {@link HashMap}<String,Object> containing initialization * parameters that can be used by the party. */ public Parameters getParameters() { return parameters; } @Override public String toString() { return "Settings[" + id + "," + profile + "," + protocol + "," + progress + "," + parameters + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((parameters == null) ? 0 : parameters.hashCode()); result = prime * result + ((profile == null) ? 0 : profile.hashCode()); result = prime * result + ((progress == null) ? 0 : progress.hashCode()); result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Settings other = (Settings) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (parameters == null) { if (other.parameters != null) return false; } else if (!parameters.equals(other.parameters)) return false; if (profile == null) { if (other.profile != null) return false; } else if (!profile.equals(other.profile)) return false; if (progress == null) { if (other.progress != null) return false; } else if (!progress.equals(other.progress)) return false; if (protocol == null) { if (other.protocol != null) return false; } else if (!protocol.equals(other.protocol)) return false; return true; } }