1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.model;
20
21 import org.apache.commons.lang.builder.CompareToBuilder;
22 import org.apache.commons.lang.builder.ToStringBuilder;
23
24
25
26
27
28
29
30
31
32
33 public class Permission extends AbstractEntity {
34
35
36
37
38 public static final PermissionPropertiesComparator PERMISSION_PROPERTIES_COMPARATOR = new PermissionPropertiesComparator();
39
40
41
42 private static final long serialVersionUID = 1L;
43
44
45
46
47 private PermissionType type;
48
49
50
51
52
53 private Project project;
54
55
56
57
58 private User user;
59
60
61
62
63
64
65
66
67
68
69 public Permission() {
70 }
71
72
73
74
75
76
77
78 public Permission(PermissionType type, User user) {
79 this(type, user, null);
80 }
81
82
83
84
85
86
87
88
89
90 public Permission(PermissionType type, User user, Project project) {
91 setPermissionType(type);
92 setUser(user);
93 setProject(project);
94 }
95
96 public PermissionType getPermissionType() {
97 return type;
98 }
99
100 public void setPermissionType(PermissionType type) {
101 this.type = type;
102 }
103
104 public User getUser() {
105 return user;
106 }
107
108 public void setUser(User user) {
109 if (user == null) {
110 throw new IllegalArgumentException("null user");
111 }
112 this.user = user;
113 }
114
115 public Project getProject() {
116 return project;
117 }
118
119
120
121
122 public void setProject(Project project) {
123 this.project = project;
124 }
125
126
127 @Override
128 public String toString() {
129 return new ToStringBuilder(this).append("id", getId()).append("type", getPermissionType())
130 .append("user", getUser()).append("project", getProject()).toString();
131 }
132
133
134 public static final class PermissionPropertiesComparator implements java.util.Comparator<Permission> {
135 public int compare(Permission"../../../org/itracker/model/Permission.html#Permission">Permission lhs, Permission rhs) {
136 return new CompareToBuilder().append(lhs.type, rhs.type).append(lhs.user, rhs.user, User.NAME_COMPARATOR).append(lhs.project, rhs.project, Project.PROJECT_COMPARATOR).toComparison();
137 }
138 }
139 }