1   /**
2    * Copyright (c) 2000-2007 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   *
32   */
33  public class PermissionDisplay implements Comparable, Serializable {
34  
35      public PermissionDisplay(Permission permission, Resource resource,
36                               String resourceName, String resourceNameParam,
37                               String resourceLabel, String actionId,
38                               String actionLabel) {
39  
40          _permission = permission;
41          _resource = resource;
42          _resourceName = resourceName;
43          _resourceNameParam = resourceNameParam;
44          _resourceLabel = resourceLabel;
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 getResourceName() {
58          return _resourceName;
59      }
60  
61      public String getResourceNameParam() {
62          return _resourceNameParam;
63      }
64  
65      public String getResourceLabel() {
66          return _resourceLabel;
67      }
68  
69      public String getActionId() {
70          return _actionId;
71      }
72  
73      public String getActionLabel() {
74          return _actionLabel;
75      }
76  
77      public int compareTo(Object obj) {
78          if (obj == null) {
79              return -1;
80          }
81  
82          PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
83  
84          int value = getResourceLabel().compareTo(
85              permissionDisplay.getResourceLabel());
86  
87          if (value == 0) {
88              value = getActionLabel().compareTo(
89                  permissionDisplay.getActionLabel());
90          }
91  
92          return value;
93      }
94  
95      private Permission _permission;
96      private Resource _resource;
97      private String _resourceName;
98      private String _resourceNameParam;
99      private String _resourceLabel;
100     private String _actionId;
101     private String _actionLabel;
102 
103 }