1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model;
16  
17  import java.io.Serializable;
18  
19  /**
20   * <a href="PermissionDisplay.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Brian Wing Shun Chan
23   * @author Jorge Ferrer
24   */
25  public class PermissionDisplay
26      implements Comparable<PermissionDisplay>, Serializable {
27  
28      public PermissionDisplay(
29          Permission permission, Resource resource, String portletName,
30          String portletLabel, String modelName, String modelLabel,
31          String actionId, String actionLabel) {
32  
33          _permission = permission;
34          _resource = resource;
35          _portletName = portletName;
36          _portletLabel = portletLabel;
37          _modelName = modelName;
38          _modelLabel = modelLabel;
39          _actionId = actionId;
40          _actionLabel = actionLabel;
41      }
42  
43      public Permission getPermission() {
44          return _permission;
45      }
46  
47      public Resource getResource() {
48          return _resource;
49      }
50  
51      public String getPortletName() {
52          return _portletName;
53      }
54  
55      public String getPortletLabel() {
56          return _portletLabel;
57      }
58  
59      public String getModelName() {
60          return _modelName;
61      }
62  
63      public String getModelLabel() {
64          return _modelLabel;
65      }
66  
67      public String getActionId() {
68          return _actionId;
69      }
70  
71      public String getActionLabel() {
72          return _actionLabel;
73      }
74  
75      public int compareTo(PermissionDisplay permissionDisplay) {
76          int value = getPortletLabel().compareTo(
77              permissionDisplay.getPortletLabel());
78  
79          if (value == 0) {
80              value = getModelLabel().compareTo(
81                  permissionDisplay.getModelLabel());
82  
83              if (value == 0) {
84                  value = getActionLabel().compareTo(
85                      permissionDisplay.getActionLabel());
86              }
87          }
88  
89          return value;
90      }
91  
92      public boolean equals(Object obj) {
93          if (obj == null) {
94              return false;
95          }
96  
97          if (!(obj instanceof PermissionDisplay)) {
98              return false;
99          }
100 
101         PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
102 
103         if (_portletName.equals(permissionDisplay.getPortletName()) &&
104             _modelName.equals(permissionDisplay.getModelName()) &&
105             _actionId.equals(permissionDisplay.getActionId())) {
106 
107             return true;
108         }
109         else {
110             return false;
111         }
112     }
113 
114     private Permission _permission;
115     private Resource _resource;
116     private String _portletName;
117     private String _portletLabel;
118     private String _modelName;
119     private String _modelLabel;
120     private String _actionId;
121     private String _actionLabel;
122 
123 }