source: protocol/src/main/java/geniusweb/protocol/tournament/ProfileList.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: 1.8 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.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)
20public 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}
Note: See TracBrowser for help on using the repository browser.