1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model;
24  
25  import java.io.Serializable;
26  
27  /**
28   * <a href="PermissionDisplay.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   * @author Jorge Ferrer
32   *
33   */
34  public class PermissionDisplay
35      implements Comparable<PermissionDisplay>, Serializable {
36  
37      public PermissionDisplay(
38          Permission permission, Resource resource, String portletName,
39          String portletLabel, String modelName, String modelLabel,
40          String actionId, String actionLabel) {
41  
42          _permission = permission;
43          _resource = resource;
44          _portletName = portletName;
45          _portletLabel = portletLabel;
46          _modelName = modelName;
47          _modelLabel = modelLabel;
48          _actionId = actionId;
49          _actionLabel = actionLabel;
50      }
51  
52      public Permission getPermission() {
53          return _permission;
54      }
55  
56      public Resource getResource() {
57          return _resource;
58      }
59  
60      public String getPortletName() {
61          return _portletName;
62      }
63  
64      public String getPortletLabel() {
65          return _portletLabel;
66      }
67  
68      public String getModelName() {
69          return _modelName;
70      }
71  
72      public String getModelLabel() {
73          return _modelLabel;
74      }
75  
76      public String getActionId() {
77          return _actionId;
78      }
79  
80      public String getActionLabel() {
81          return _actionLabel;
82      }
83  
84      public int compareTo(PermissionDisplay permissionDisplay) {
85          int value = getPortletLabel().compareTo(
86              permissionDisplay.getPortletLabel());
87  
88          if (value == 0) {
89              value = getModelLabel().compareTo(
90                  permissionDisplay.getModelLabel());
91  
92              if (value == 0) {
93                  value = getActionLabel().compareTo(
94                      permissionDisplay.getActionLabel());
95              }
96          }
97  
98          return value;
99      }
100 
101     public boolean equals(Object obj) {
102         if (obj == null) {
103             return false;
104         }
105 
106         if (!(obj instanceof PermissionDisplay)) {
107             return false;
108         }
109 
110         PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
111 
112         if (_portletName.equals(permissionDisplay.getPortletName()) &&
113             _modelName.equals(permissionDisplay.getModelName()) &&
114             _actionId.equals(permissionDisplay.getActionId())) {
115 
116             return true;
117         }
118         else {
119             return false;
120         }
121     }
122 
123     private Permission _permission;
124     private Resource _resource;
125     private String _portletName;
126     private String _portletLabel;
127     private String _modelName;
128     private String _modelLabel;
129     private String _actionId;
130     private String _actionLabel;
131 
132 }