1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class PermissionDisplay
34      implements Comparable<PermissionDisplay>, Serializable {
35  
36      public PermissionDisplay(
37          Permission permission, Resource resource, String portletName,
38          String portletLabel, String modelName, String modelLabel,
39          String actionId, String actionLabel) {
40  
41          _permission = permission;
42          _resource = resource;
43          _portletName = portletName;
44          _portletLabel = portletLabel;
45          _modelName = modelName;
46          _modelLabel = modelLabel;
47          _actionId = actionId;
48          _actionLabel = actionLabel;
49      }
50  
51      public Permission getPermission() {
52          return _permission;
53      }
54  
55      public Resource getResource() {
56          return _resource;
57      }
58  
59      public String getPortletName() {
60          return _portletName;
61      }
62  
63      public String getPortletLabel() {
64          return _portletLabel;
65      }
66  
67      public String getModelName() {
68          return _modelName;
69      }
70  
71      public String getModelLabel() {
72          return _modelLabel;
73      }
74  
75      public String getActionId() {
76          return _actionId;
77      }
78  
79      public String getActionLabel() {
80          return _actionLabel;
81      }
82  
83      public int compareTo(PermissionDisplay permissionDisplay) {
84          int value = getPortletLabel().compareTo(
85              permissionDisplay.getPortletLabel());
86  
87          if (value == 0) {
88              value = getModelLabel().compareTo(
89                  permissionDisplay.getModelLabel());
90  
91              if (value == 0) {
92                  value = getActionLabel().compareTo(
93                      permissionDisplay.getActionLabel());
94              }
95          }
96  
97          return value;
98      }
99  
100     public boolean equals(Object obj) {
101         if (obj == null) {
102             return false;
103         }
104 
105         if (!(obj instanceof PermissionDisplay)) {
106             return false;
107         }
108 
109         PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
110 
111         if (_portletName.equals(permissionDisplay.getPortletName()) &&
112             _modelName.equals(permissionDisplay.getModelName()) &&
113             _actionId.equals(permissionDisplay.getActionId())) {
114 
115             return true;
116         }
117         else {
118             return false;
119         }
120     }
121 
122     private Permission _permission;
123     private Resource _resource;
124     private String _portletName;
125     private String _portletLabel;
126     private String _modelName;
127     private String _modelLabel;
128     private String _actionId;
129     private String _actionLabel;
130 
131 }