Merge "BUG-2329 Add test for anyxmls inside rpc resonse for netcfon-connector"
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / authorization / ResourceGroup.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  * Represents a group of resources along with the privilege associated to it
16  *
17  *
18  *
19  */
20 public class ResourceGroup implements Serializable {
21     private static final long serialVersionUID = 1L;
22     private String groupName; // the resource group name
23     private Privilege privilege; // the privilege for this profile on the resource group
24
25     public ResourceGroup(String groupName, Privilege privilege) {
26         this.groupName = groupName;
27         this.privilege = privilege;
28     }
29
30     /**
31      * Returns the name for this resource group
32      * @return
33      */
34     public String getGroupName() {
35         return groupName;
36     }
37
38     /**
39      * Returns the privilege for this group on its resources
40      * @return
41      */
42     public Privilege getPrivilege() {
43         return privilege;
44     }
45
46     @Override
47     public int hashCode() {
48         final int prime = 31;
49         int result = 1;
50         result = prime * result
51                 + ((groupName == null) ? 0 : groupName.hashCode());
52         result = prime * result
53                 + ((privilege == null) ? 0 : privilege.hashCode());
54         return result;
55     }
56
57     @Override
58     public boolean equals(Object obj) {
59         if (this == obj)
60             return true;
61         if (obj == null)
62             return false;
63         if (getClass() != obj.getClass())
64             return false;
65         ResourceGroup other = (ResourceGroup) obj;
66         if (groupName == null) {
67             if (other.groupName != null)
68                 return false;
69         } else if (!groupName.equals(other.groupName))
70             return false;
71         if (privilege != other.privilege)
72             return false;
73         return true;
74     }
75
76     @Override
77     public String toString() {
78         return "[" + groupName + ", " + privilege.toString() + "]";
79     }
80 }