View Javadoc
1   /*
2    * Copyright (C) 2003-2011 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.wiki.mow.api;
18  
19  public class Permission {
20    private PermissionType permissionType;
21  
22    private boolean isAllowed = false;
23  
24    public Permission() {
25    }
26  
27    public Permission(PermissionType permissionType, boolean isAllowed) {
28      this.permissionType = permissionType;
29      this.isAllowed = isAllowed;
30    }
31  
32    public PermissionType getPermissionType() {
33      return permissionType;
34    }
35  
36    public void setPermissionType(PermissionType permissionType) {
37      this.permissionType = permissionType;
38    }
39  
40    public boolean isAllowed() {
41      return isAllowed;
42    }
43  
44    public void setAllowed(boolean isAllowed) {
45      this.isAllowed = isAllowed;
46    }
47  
48    @Override
49    public boolean equals(Object o) {
50      if (this == o) return true;
51      if (!(o instanceof Permission)) return false;
52  
53      Permission that = (Permission) o;
54  
55      if (isAllowed != that.isAllowed) return false;
56      if (permissionType != that.permissionType) return false;
57  
58      return true;
59    }
60  
61    @Override
62    public int hashCode() {
63      int result = permissionType != null ? permissionType.hashCode() : 0;
64      result = 31 * result + (isAllowed ? 1 : 0);
65      return result;
66    }
67  }