001
014
015 package com.liferay.portal.model;
016
017 import java.io.Serializable;
018
019
023 public class PermissionDisplay
024 implements Comparable<PermissionDisplay>, Serializable {
025
026 public PermissionDisplay(
027 Permission permission, Resource resource, String portletName,
028 String portletLabel, String modelName, String modelLabel,
029 String actionId, String actionLabel) {
030
031 _permission = permission;
032 _resource = resource;
033 _portletName = portletName;
034 _portletLabel = portletLabel;
035 _modelName = modelName;
036 _modelLabel = modelLabel;
037 _actionId = actionId;
038 _actionLabel = actionLabel;
039 }
040
041 public Permission getPermission() {
042 return _permission;
043 }
044
045 public Resource getResource() {
046 return _resource;
047 }
048
049 public String getPortletName() {
050 return _portletName;
051 }
052
053 public String getPortletLabel() {
054 return _portletLabel;
055 }
056
057 public String getModelName() {
058 return _modelName;
059 }
060
061 public String getModelLabel() {
062 return _modelLabel;
063 }
064
065 public String getActionId() {
066 return _actionId;
067 }
068
069 public String getActionLabel() {
070 return _actionLabel;
071 }
072
073 public int compareTo(PermissionDisplay permissionDisplay) {
074 int value = getPortletLabel().compareTo(
075 permissionDisplay.getPortletLabel());
076
077 if (value == 0) {
078 value = getModelLabel().compareTo(
079 permissionDisplay.getModelLabel());
080
081 if (value == 0) {
082 value = getActionLabel().compareTo(
083 permissionDisplay.getActionLabel());
084 }
085 }
086
087 return value;
088 }
089
090 @Override
091 public boolean equals(Object obj) {
092 if (obj == null) {
093 return false;
094 }
095
096 if (!(obj instanceof PermissionDisplay)) {
097 return false;
098 }
099
100 PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
101
102 if (_portletName.equals(permissionDisplay.getPortletName()) &&
103 _modelName.equals(permissionDisplay.getModelName()) &&
104 _actionId.equals(permissionDisplay.getActionId())) {
105
106 return true;
107 }
108 else {
109 return false;
110 }
111 }
112
113 @Override
114 public int hashCode() {
115 return _portletName.concat(_modelName).concat(_actionId).hashCode();
116 }
117
118 private Permission _permission;
119 private Resource _resource;
120 private String _portletName;
121 private String _portletLabel;
122 private String _modelName;
123 private String _modelLabel;
124 private String _actionId;
125 private String _actionLabel;
126
127 }