blob: 75d9433f60514077461810da23821accb992332b [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
19public class Permission {
20
21 protected String classname;
22 protected String name;
23 protected String actions;
24
25 public Permission(String classname, String name, String actions) {
26 this.classname = classname;
27 this.name = name;
28 if (actions == null) {
29 this.actions = "";
30 } else {
31 this.actions = actions;
32 }
33 }
34
35 public Permission(String classname, String name) {
36 this.classname = classname;
37 this.name = name;
38 this.actions = "";
39 }
40
41 public String getClassName() {
42 return classname;
43 }
44
45 public String getName() {
46 return name;
47 }
48
49 public String getActions() {
50 return actions;
51 }
52
53 @Override
54 public int hashCode() {
55 return 0;
56 }
57
58 @Override
59 public boolean equals(Object thatPerm) {
60 if (this == thatPerm) {
61 return true;
62 }
63
64 if (!(thatPerm instanceof Permission)) {
65 return false;
66 }
67
68 Permission that = (Permission) thatPerm;
69 return (this.classname.equals(that.classname)) && (this.name.equals(that.name))
70 && (this.actions.equals(that.actions));
71 }
72
73 @Override
74 public String toString() {
75 return String.format("(%s, %s, %s)", classname, name, actions);
76 }
77}