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.ProfileRef;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Contains a list of profiles, one for each {@link Team} member.
|
---|
17 | */
|
---|
18 | @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
|
---|
19 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
|
---|
20 | public class ProfileList {
|
---|
21 | @JsonValue
|
---|
22 | private final List<ProfileRef> profiles; // field to ensure immutability
|
---|
23 |
|
---|
24 | /**
|
---|
25 | *
|
---|
26 | * @param ps a list of {@link ProfileRef}s. The length and order is
|
---|
27 | * important as each will be matched with the {@link Team} member
|
---|
28 | * at the same index.
|
---|
29 | */
|
---|
30 | @JsonCreator
|
---|
31 | public ProfileList(List<ProfileRef> ps) {
|
---|
32 | this.profiles = new ArrayList<>(ps);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public List<ProfileRef> getProfiles() {
|
---|
36 | return Collections.unmodifiableList(profiles);
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | public int hashCode() {
|
---|
41 | final int prime = 31;
|
---|
42 | int result = 1;
|
---|
43 | result = prime * result
|
---|
44 | + ((profiles == null) ? 0 : profiles.hashCode());
|
---|
45 | return result;
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public boolean equals(Object obj) {
|
---|
50 | if (this == obj)
|
---|
51 | return true;
|
---|
52 | if (obj == null)
|
---|
53 | return false;
|
---|
54 | if (getClass() != obj.getClass())
|
---|
55 | return false;
|
---|
56 | ProfileList other = (ProfileList) obj;
|
---|
57 | if (profiles == null) {
|
---|
58 | if (other.profiles != null)
|
---|
59 | return false;
|
---|
60 | } else if (!profiles.equals(other.profiles))
|
---|
61 | return false;
|
---|
62 | return true;
|
---|
63 | }
|
---|
64 |
|
---|
65 | public String toString() {
|
---|
66 | return profiles.toString();
|
---|
67 | }
|
---|
68 | }
|
---|