blob: 0c874c9d49bac878b3005dcb2256aa938f6f1bcc [file] [log] [blame]
Changhoon Yoonb856b812015-08-10 03:47:19 +09001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.security;
18
Thomas Vachuska4c571ae2015-09-10 16:31:59 -070019import com.google.common.annotations.Beta;
20
21@Beta
Changhoon Yoonb856b812015-08-10 03:47:19 +090022public class Permission {
23
24 protected String classname;
25 protected String name;
26 protected String actions;
27
28 public Permission(String classname, String name, String actions) {
29 this.classname = classname;
30 this.name = name;
31 if (actions == null) {
32 this.actions = "";
33 } else {
34 this.actions = actions;
35 }
36 }
37
38 public Permission(String classname, String name) {
39 this.classname = classname;
40 this.name = name;
41 this.actions = "";
42 }
43
44 public String getClassName() {
45 return classname;
46 }
47
48 public String getName() {
49 return name;
50 }
51
52 public String getActions() {
53 return actions;
54 }
55
56 @Override
57 public int hashCode() {
58 return 0;
59 }
60
61 @Override
62 public boolean equals(Object thatPerm) {
63 if (this == thatPerm) {
64 return true;
65 }
66
67 if (!(thatPerm instanceof Permission)) {
68 return false;
69 }
70
71 Permission that = (Permission) thatPerm;
72 return (this.classname.equals(that.classname)) && (this.name.equals(that.name))
73 && (this.actions.equals(that.actions));
74 }
75
76 @Override
77 public String toString() {
78 return String.format("(%s, %s, %s)", classname, name, actions);
79 }
80}