Changeset 8 for party/src


Ignore:
Timestamp:
09/30/19 15:37:05 (5 years ago)
Author:
bart
Message:

Added parameter support

Location:
party/src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • party/src/main/java/geniusweb/party/inform/Settings.java

    r1 r8  
    11package geniusweb.party.inform;
     2
     3import java.util.HashMap;
    24
    35import com.fasterxml.jackson.annotation.JsonCreator;
     
    57
    68import geniusweb.actions.PartyId;
     9import geniusweb.party.Party;
    710import geniusweb.progress.Progress;
     11import geniusweb.references.Parameters;
    812import geniusweb.references.ProfileRef;
    913import geniusweb.references.ProtocolRef;
    1014
    1115/**
    12  * Informs a party about all settings for the upcoming negotiation session. This
    13  * should be sent to a party one time, so that the party knows the situation.
     16 * Informs a {@link Party} about all settings for the upcoming negotiation
     17 * session. This should be sent to a party one time, so that the party knows the
     18 * situation.
    1419 *
    1520 */
     
    1924        private Progress progress;
    2025        private PartyId id;
     26        private Parameters parameters;
    2127
     28        /**
     29         *
     30         * @param id         the {@link PartyId} for this party
     31         * @param profile    the profile used for this party in this session
     32         * @param protocol   the protocol used in this session
     33         * @param progress   the {@link Progress} object used for this session
     34         * @param parameters a Map<String, Object> containing initialization
     35         *                   parameters for this party. The Object can be a HashMap,
     36         *                   ArrayList, String, or number (Integer, Double, etc).
     37         *                   The Object should not be just any Object because
     38         *                   deserialization will work only with the mentioned
     39         *                   types.
     40         */
    2241        @JsonCreator
    2342        public Settings(@JsonProperty("id") PartyId id,
    2443                        @JsonProperty("profile") ProfileRef profile,
    2544                        @JsonProperty("protocol") ProtocolRef protocol,
    26                         @JsonProperty("progress") Progress progress) {
    27                 if (profile == null || protocol == null || progress == null) {
     45                        @JsonProperty("progress") Progress progress,
     46                        @JsonProperty("parameters") Parameters parameters) {
     47                if (profile == null || protocol == null || progress == null
     48                                || parameters == null) {
    2849                        throw new IllegalArgumentException(
    29                                         "party, profile, protocol and progress must be not null.");
     50                                        "party, profile, protocol, parameters and progress must be not null.");
    3051                }
    3152                this.profile = profile;
    3253                this.protocol = protocol;
    3354                this.progress = progress;
     55                this.parameters = parameters;
    3456                this.id = id;
    3557        }
    3658
     59        /**
     60         *
     61         * @return the profile used for this party in this session
     62         */
    3763        public ProfileRef getProfile() {
    3864                return profile;
     
    4369        }
    4470
     71        /**
     72         *
     73         * @return the {@link Progress} object used for this session
     74         */
    4575        public Progress getProgress() {
    4676                return progress;
    4777        }
    4878
     79        /**
     80         * @return the party ID of this party
     81         */
    4982        public PartyId getID() {
    5083                return id;
     84        }
     85
     86        /**
     87         *
     88         * @return a HashMap<String,Object> containing initialization parameters
     89         *         that can be used by the party.
     90         */
     91        public HashMap<String, Object> getParemeters() {
     92                return parameters;
    5193        }
    5294
     
    5496        public String toString() {
    5597                return "Settings[" + id + "," + profile + "," + protocol + ","
    56                                 + progress + "]";
     98                                + progress + "," + parameters + "]";
    5799        }
    58100
     
    62104                int result = 1;
    63105                result = prime * result + ((id == null) ? 0 : id.hashCode());
     106                result = prime * result
     107                                + ((parameters == null) ? 0 : parameters.hashCode());
    64108                result = prime * result + ((profile == null) ? 0 : profile.hashCode());
    65109                result = prime * result
     
    84128                } else if (!id.equals(other.id))
    85129                        return false;
     130                if (parameters == null) {
     131                        if (other.parameters != null)
     132                                return false;
     133                } else if (!parameters.equals(other.parameters))
     134                        return false;
    86135                if (profile == null) {
    87136                        if (other.profile != null)
Note: See TracChangeset for help on using the changeset viewer.