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
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
24 public Resource(Object resource, Privilege privilege) {
25 this.resource = resource;
26 this.privilege = privilege;
29 public Object getResource() {
33 public Privilege getPrivilege() {
38 public int hashCode() {
41 result = prime * result
42 + ((privilege == null) ? 0 : privilege.hashCode());
43 result = prime * result
44 + ((resource == null) ? 0 : resource.hashCode());
49 public boolean equals(Object obj) {
54 if (getClass() != obj.getClass())
56 Resource other = (Resource) obj;
57 if (privilege != other.privilege)
59 if (resource == null) {
60 if (other.resource != null)
62 } else if (!resource.equals(other.resource))
68 public String toString() {
69 return "[" + resource + ", " + privilege.toString() + "]";