source: src/main/java/genius/core/session/Participant.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.9 KB
Line 
1package genius.core.session;
2
3import genius.core.AgentID;
4import genius.core.parties.Mediator;
5import genius.core.repository.ParticipantRepItem;
6import genius.core.repository.ProfileRepItem;
7
8/**
9 * Contains full participant info: the party name, strategy and profile.
10 * Equality only involves the party NAME, as names should be unique in a
11 * negotiation. mediators are also participants. immutable.
12 */
13public class Participant {
14 private AgentID id;
15 private ParticipantRepItem strategy;
16 private ProfileRepItem profile;
17
18 /**
19 *
20 * @param id
21 * the agent ID
22 * @param party
23 * the {@link ParticipantRepItem} to use for this participant.
24 * @param profile
25 * The profile that this participant uses. can be null if this
26 * participant does not need a profile (eg, {@link Mediator}.
27 */
28 public Participant(AgentID id, ParticipantRepItem party,
29 ProfileRepItem profile) {
30 if (id == null || party == null || profile == null) {
31 throw new IllegalArgumentException("parameter is null");
32 }
33 this.id = id;
34 this.strategy = party;
35 this.profile = profile;
36 }
37
38 public AgentID getId() {
39 return id;
40 }
41
42 public ParticipantRepItem getStrategy() {
43 return strategy;
44 }
45
46 public ProfileRepItem getProfile() {
47 return profile;
48 }
49
50 @Override
51 public int hashCode() {
52 final int prime = 31;
53 int result = 1;
54 result = prime * result + ((id == null) ? 0 : id.hashCode());
55 return result;
56 }
57
58 /**
59 * Equals is based only on the agent id.
60 */
61 @Override
62 public boolean equals(Object obj) {
63 if (this == obj)
64 return true;
65 if (obj == null)
66 return false;
67 if (getClass() != obj.getClass())
68 return false;
69 Participant other = (Participant) obj;
70 if (id == null) {
71 if (other.id != null)
72 return false;
73 } else if (!id.equals(other.id))
74 return false;
75 return true;
76 }
77
78 @Override
79 public String toString() {
80 return "Participant[" + id + "," + strategy + "," + profile + "]";
81 }
82
83}
Note: See TracBrowser for help on using the repository browser.