source: protocol/src/main/java/geniusweb/protocol/tournament/Team.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 2.1 KB
Line 
1package geniusweb.protocol.tournament;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.List;
6
7import com.fasterxml.jackson.annotation.JsonAutoDetect;
8import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
9import com.fasterxml.jackson.annotation.JsonCreator;
10import com.fasterxml.jackson.annotation.JsonTypeInfo;
11import com.fasterxml.jackson.annotation.JsonValue;
12
13import geniusweb.references.PartyWithParameters;
14
15/**
16 * A team is a group of parties, each with their own parameters. Each will be
17 * coupled to a {@link ProfileList} in the generation phase of the protocol
18 *
19 */
20@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
21@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
22public class Team {
23 @JsonValue
24 private final List<PartyWithParameters> parties; // ensure immutability
25
26 /**
27 *
28 * @param ps a list of {@link PartyWithParameters}. Each party is always
29 * associated with the given parameters. The order of them is
30 * important as it will be matched with the order in the
31 * {@link ProfileList}.
32 */
33 @JsonCreator
34 public Team(List<PartyWithParameters> ps) {
35 this.parties = new ArrayList<PartyWithParameters>(ps);
36 }
37
38 /**
39 *
40 * @return list of all team {@link PartyWithParameters}.
41 */
42 public List<PartyWithParameters> getParties() {
43 return Collections.unmodifiableList(parties);
44 }
45
46 @Override
47 public int hashCode() {
48 final int prime = 31;
49 int result = 1;
50 result = prime * result + ((parties == null) ? 0 : parties.hashCode());
51 return result;
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj)
57 return true;
58 if (obj == null)
59 return false;
60 if (getClass() != obj.getClass())
61 return false;
62 Team other = (Team) obj;
63 if (parties == null) {
64 if (other.parties != null)
65 return false;
66 } else if (!parties.equals(other.parties))
67 return false;
68 return true;
69 }
70
71 public String toString() {
72 return parties.toString();
73 }
74}
Note: See TracBrowser for help on using the repository browser.