3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
10 package org.opendaylight.controller.sal.authorization;
12 import java.io.Serializable;
15 * It represents the elementary resource along with
16 * the access privilege associated to it
18 public class Resource implements Serializable {
19 private static final long serialVersionUID = 1L;
20 Object resource; // the generic resource
21 Privilege privilege; // read/use/write privilege
23 public Resource(Object resource, Privilege privilege) {
24 this.resource = resource;
25 this.privilege = privilege;
28 public Object getResource() {
32 public Privilege getPrivilege() {
37 public int hashCode() {
40 result = prime * result
41 + ((privilege == null) ? 0 : privilege.hashCode());
42 result = prime * result
43 + ((resource == null) ? 0 : resource.hashCode());
48 public boolean equals(Object obj) {
53 if (getClass() != obj.getClass())
55 Resource other = (Resource) obj;
56 if (privilege != other.privilege)
58 if (resource == null) {
59 if (other.resource != null)
61 } else if (!resource.equals(other.resource))
67 public String toString() {
68 return "[" + resource + ", " + privilege.toString() + "]";