1 /** 2 * Copyright 2010, CSIRO Australia. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package au.csiro.netcdf.cli; 18 19 import java.util.Comparator; 20 21 import org.apache.commons.cli.Option; 22 23 /** 24 * This class implements the <code>Comparator</code> interface for comparing Options. 25 * 26 * Copyright 2010, CSIRO Australia 27 * All rights reserved. 28 * 29 * @author Robert Bridle on 19/03/2010 30 * @version $Revision: 78 $ $Date: 2010-07-24 16:23:13 +1000 (Sat, 24 Jul 2010) $ 31 */ 32 public class CommandLineOptionsComparator implements Comparator<Option> 33 { 34 /** 35 * Compares its two arguments for order. Returns a negative 36 * integer, zero, or a positive integer as the first argument 37 * is less than, equal to, or greater than the second. 38 * 39 * @param o1 The first Option to be compared. 40 * @param o2 The second Option to be compared. 41 * @return a negative integer, zero, or a positive integer as 42 * the first argument is less than, equal to, or greater than the 43 * second. 44 */ 45 @Override 46 public int compare(Option o1, Option o2) 47 { 48 return o1.getDescription().compareToIgnoreCase(o2.getDescription()); 49 } 50 }