1 | package geniusweb.protocol.tournament;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.Collections;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
---|
8 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
---|
9 | import com.fasterxml.jackson.annotation.JsonCreator;
|
---|
10 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
---|
11 | import com.fasterxml.jackson.annotation.JsonValue;
|
---|
12 |
|
---|
13 | import 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)
|
---|
22 | public 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 | }
|
---|