[ all classes ]
[ com.acciente.oacc ]
Coverage Summary for Class: SysPermission (com.acciente.oacc)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
SysPermission | 100% (1/ 1) | 60% (3/ 5) | 34.8% (8/ 23) |
1 /*
2 * Copyright 2009-2018, Acciente LLC
3 *
4 * Acciente LLC licenses this file to you under the
5 * Apache License, Version 2.0 (the "License"); you
6 * may not use this file except in compliance with the
7 * License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
14 * OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License.
17 */
18 package com.acciente.oacc;
19
20 import java.io.Serializable;
21
22 class SysPermission implements Serializable {
23 private static final long serialVersionUID = 1L;
24
25 private final long systemPermissionId;
26 private final String permissionName;
27
28 SysPermission(int systemPermissionId, String permissionName) {
29 if (systemPermissionId == 0) {
30 throw new IllegalArgumentException("System permission ID must be non-zero");
31 }
32
33 if (!permissionName.startsWith("*")) {
34 throw new IllegalArgumentException("System permission names MUST start with *");
35 }
36
37 this.systemPermissionId = systemPermissionId;
38 this.permissionName = permissionName.intern();
39 }
40
41 public long getSystemPermissionId() {
42 return systemPermissionId;
43 }
44
45 public String getPermissionName() {
46 return permissionName;
47 }
48
49 @Override
50 public int hashCode() {
51 int result = (int) (systemPermissionId ^ (systemPermissionId >>> 32));
52 result = 31 * result + permissionName.hashCode();
53 return result;
54 }
55
56 @Override
57 public boolean equals(Object o) {
58 if (this == o) {
59 return true;
60 }
61 if (o == null || getClass() != o.getClass()) {
62 return false;
63 }
64
65 SysPermission that = (SysPermission) o;
66
67 if (systemPermissionId != that.systemPermissionId) {
68 return false;
69 }
70 if (!permissionName.equals(that.permissionName)) {
71 return false;
72 }
73
74 return true;
75 }
76 }