| PermissionActionIdComparator.java |
1 /**
2 * Copyright (c) 2000-2010 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 *
12 *
13 */
14
15 package com.liferay.portal.security.permission.comparator;
16
17 import com.liferay.portal.model.Permission;
18
19 import java.io.Serializable;
20
21 import java.util.Comparator;
22
23 /**
24 * <a href="PermissionActionIdComparator.java.html"><b><i>View Source</i></b>
25 * </a>
26 *
27 * @author Brian Wing Shun Chan
28 */
29 public class PermissionActionIdComparator
30 implements Comparator<Object>, Serializable {
31
32 public int compare(Object obj1, Object obj2) {
33 String actionId1 = null;
34
35 if (obj1 instanceof String) {
36 actionId1 = (String)obj1;
37 }
38 else {
39 Permission permission1 = (Permission)obj1;
40
41 actionId1 = permission1.getActionId();
42 }
43
44 String actionId2 = null;
45
46 if (obj2 instanceof String) {
47 actionId2 = (String)obj2;
48 }
49 else {
50 Permission permission2 = (Permission)obj2;
51
52 actionId2 = permission2.getActionId();
53 }
54
55 return actionId1.compareTo(actionId2);
56 }
57
58 }