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 @Override
042 public int compareTo(PermissionDisplay permissionDisplay) {
043 int value = getPortletLabel().compareTo(
044 permissionDisplay.getPortletLabel());
045
046 if (value == 0) {
047 value = getModelLabel().compareTo(
048 permissionDisplay.getModelLabel());
049
050 if (value == 0) {
051 value = getActionLabel().compareTo(
052 permissionDisplay.getActionLabel());
053 }
054 }
055
056 return value;
057 }
058
059 @Override
060 public boolean equals(Object obj) {
061 if (this == obj) {
062 return true;
063 }
064
065 if (!(obj instanceof PermissionDisplay)) {
066 return false;
067 }
068
069 PermissionDisplay permissionDisplay = (PermissionDisplay)obj;
070
071 if (_portletName.equals(permissionDisplay.getPortletName()) &&
072 _modelName.equals(permissionDisplay.getModelName()) &&
073 _actionId.equals(permissionDisplay.getActionId())) {
074
075 return true;
076 }
077 else {
078 return false;
079 }
080 }
081
082 public String getActionId() {
083 return _actionId;
084 }
085
086 public String getActionLabel() {
087 return _actionLabel;
088 }
089
090 public String getModelLabel() {
091 return _modelLabel;
092 }
093
094 public String getModelName() {
095 return _modelName;
096 }
097
098 public Permission getPermission() {
099 return _permission;
100 }
101
102 public String getPortletLabel() {
103 return _portletLabel;
104 }
105
106 public String getPortletName() {
107 return _portletName;
108 }
109
110 public Resource getResource() {
111 return _resource;
112 }
113
114 @Override
115 public int hashCode() {
116 return _portletName.concat(_modelName).concat(_actionId).hashCode();
117 }
118
119 private String _actionId;
120 private String _actionLabel;
121 private String _modelLabel;
122 private String _modelName;
123 private Permission _permission;
124 private String _portletLabel;
125 private String _portletName;
126 private Resource _resource;
127
128 }