source: party/src/main/java/geniusweb/party/Capabilities.java@ 27

Last change on this file since 27 was 27, checked in by bart, 4 years ago
  • party capabilities now include profile information. Existing parties may need small fix * plot layout shows accepts * VotingEvaluator use group power instead of group size * runsession you can now also select MOPAC-only parties
File size: 2.2 KB
Line 
1package geniusweb.party;
2
3import java.util.Set;
4
5import com.fasterxml.jackson.annotation.JsonAutoDetect;
6import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
7import com.fasterxml.jackson.annotation.JsonCreator;
8import com.fasterxml.jackson.annotation.JsonProperty;
9
10import geniusweb.profile.Profile;
11
12/**
13 * The capabilities of a party
14 */
15@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
16public class Capabilities {
17 /**
18 * List of supported protocol names
19 */
20 private final Set<String> behaviours;
21 /**
22 * The profile classes that are supported
23 */
24 private final Set<Class<? extends Profile>> profiles;
25
26 /**
27 *
28 * @param behaviours the protocols that a Party can handle
29 */
30 @JsonCreator
31 public Capabilities(@JsonProperty("behaviours") Set<String> behaviours,
32 @JsonProperty("profiles") Set<Class<? extends Profile>> profiles) {
33 if (behaviours == null) {
34 throw new IllegalArgumentException("behaviours==null");
35 }
36 for (Class<? extends Profile> prof : profiles) {
37 if (!Profile.class.isAssignableFrom(prof))
38 throw new IllegalArgumentException(
39 "profile " + prof + " must be a subclass of Profile");
40 }
41 this.behaviours = behaviours;
42 this.profiles = profiles;
43 }
44
45 /**
46 *
47 * @return the behaviours (protocols) that are supported
48 */
49 public Set<String> getBehaviours() {
50 return behaviours;
51 }
52
53 /**
54 *
55 * @return the profile classes that are supported
56 *
57 */
58 public Set<Class<? extends Profile>> getProfiles() {
59 return profiles;
60 }
61
62 @Override
63 public int hashCode() {
64 final int prime = 31;
65 int result = 1;
66 result = prime * result
67 + ((behaviours == null) ? 0 : behaviours.hashCode());
68 return result;
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj)
74 return true;
75 if (obj == null)
76 return false;
77 if (getClass() != obj.getClass())
78 return false;
79 Capabilities other = (Capabilities) obj;
80 if (behaviours == null) {
81 if (other.behaviours != null)
82 return false;
83 } else if (!behaviours.equals(other.behaviours))
84 return false;
85 return true;
86 }
87
88 @Override
89 public String toString() {
90 return "Capabilities[" + "Behaviours=" + behaviours + "]";
91 }
92
93}
Note: See TracBrowser for help on using the repository browser.