1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.acl;
21
22 import com.fasterxml.jackson.annotation.JsonValue;
23 import com.google.common.collect.ImmutableMap;
24
25 import java.util.Map;
26
27
28
29
30 class AccessorPermissions<T> {
31 final String accessorId;
32 final T permissionSet;
33
34 public AccessorPermissions(String accessorId, T permissionSet) {
35 this.accessorId = accessorId;
36 this.permissionSet = permissionSet;
37 }
38
39 @JsonValue
40 public Map<String, T> asMap() {
41 return ImmutableMap.of(accessorId, permissionSet);
42 }
43
44 @Override
45 public boolean equals(Object o) {
46 if (this == o) return true;
47 if (o == null || getClass() != o.getClass()) return false;
48
49 AccessorPermissions that = (AccessorPermissions) o;
50
51 return accessorId.equals(that.accessorId)
52 && permissionSet.equals(that.permissionSet);
53
54 }
55
56 @Override
57 public int hashCode() {
58 int result = accessorId.hashCode();
59 result = 31 * result + permissionSet.hashCode();
60 return result;
61 }
62
63 @Override
64 public String toString() {
65 return "<" + accessorId + " " + permissionSet + ">";
66 }
67 }