001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Nuxeo - initial API and implementation 011 * 012 * $Id: PermissionUIItemComparator.java 28304 2007-12-21 12:13:32Z ogrisel $ 013 */ 014package org.nuxeo.ecm.core.security; 015 016import java.io.Serializable; 017import java.util.Comparator; 018 019/** 020 * @author <a href="mailto:ogrisel@nuxeo.com">Olivier Grisel</a> 021 */ 022public class PermissionUIItemComparator implements Comparator<PermissionUIItemDescriptor>, Serializable { 023 024 private static final long serialVersionUID = 6468292882222351585L; 025 026 @Override 027 public int compare(PermissionUIItemDescriptor pid1, PermissionUIItemDescriptor pid2) { 028 int diff = pid2.getOrder() - pid1.getOrder(); 029 if (diff == 0) { 030 return 0; 031 } else if (diff > 0) { // ascending order 032 return -1; 033 } else { 034 return 1; 035 } 036 } 037 038}