Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / authorization / Resource.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.authorization;
11
12 import java.io.Serializable;
13
14 /**
15  * It represents the elementary resource along with
16  * the access privilege associated to it
17  */
18 @Deprecated
19 public class Resource implements Serializable {
20     private static final long serialVersionUID = 1L;
21     Object resource; // the generic resource
22     Privilege privilege; // read/use/write privilege
23
24     public Resource(Object resource, Privilege privilege) {
25         this.resource = resource;
26         this.privilege = privilege;
27     }
28
29     public Object getResource() {
30         return resource;
31     }
32
33     public Privilege getPrivilege() {
34         return privilege;
35     }
36
37     @Override
38     public int hashCode() {
39         final int prime = 31;
40         int result = 1;
41         result = prime * result
42                 + ((privilege == null) ? 0 : privilege.hashCode());
43         result = prime * result
44                 + ((resource == null) ? 0 : resource.hashCode());
45         return result;
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         if (this == obj)
51             return true;
52         if (obj == null)
53             return false;
54         if (getClass() != obj.getClass())
55             return false;
56         Resource other = (Resource) obj;
57         if (privilege != other.privilege)
58             return false;
59         if (resource == null) {
60             if (other.resource != null)
61                 return false;
62         } else if (!resource.equals(other.resource))
63             return false;
64         return true;
65     }
66
67     @Override
68     public String toString() {
69         return "[" + resource + ", " + privilege.toString() + "]";
70     }
71 }