| PermissionActionIdComparator.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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 }