Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / 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 import org.apache.commons.lang3.builder.EqualsBuilder;
15 import org.apache.commons.lang3.builder.HashCodeBuilder;
16
17 /**
18  * It represents the elementary resource along with
19  * the access privilege associated to it
20  */
21 public class Resource implements Serializable {
22     private static final long serialVersionUID = 1L;
23     Object resource; // the generic resource
24     Privilege privilege; // read/use/write privilege
25
26     public Resource(Object resource, Privilege privilege) {
27         this.resource = resource;
28         this.privilege = privilege;
29     }
30
31     public Object getResource() {
32         return resource;
33     }
34
35     public Privilege getPrivilege() {
36         return privilege;
37     }
38
39     @Override
40     public int hashCode() {
41         return HashCodeBuilder.reflectionHashCode(this);
42     }
43
44     @Override
45     public boolean equals(Object obj) {
46         return EqualsBuilder.reflectionEquals(this, obj);
47     }
48
49     @Override
50     public String toString() {
51         return "[" + resource + ", " + privilege.toString() + "]";
52     }
53 }