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