blob: 6db7565485df540c241a8a5aa4b590aac89c8123 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2003, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.keys;
import java.util.Comparator;
import org.eclipse.ui.keys.ModifierKey;
abstract class AbstractModifierKeyComparator implements Comparator {
public int compare(Object left, Object right) {
ModifierKey modifierKeyLeft = (ModifierKey) left;
ModifierKey modifierKeyRight = (ModifierKey) right;
int modifierKeyLeftRank = rank(modifierKeyLeft);
int modifierKeyRightRank = rank(modifierKeyRight);
if (modifierKeyLeftRank != modifierKeyRightRank) {
return modifierKeyLeftRank - modifierKeyRightRank;
} else {
return modifierKeyLeft.compareTo(modifierKeyRight);
}
}
protected abstract int rank(ModifierKey modifierKey);
}