001 package edu.nrao.sss.model.resource.sort; 002 003 import java.util.Comparator; 004 005 import edu.nrao.sss.model.resource.Resource; 006 import edu.nrao.sss.sort.SortKey; 007 import edu.nrao.sss.sort.SortOrder; 008 import edu.nrao.sss.sort.StringSortKey; 009 010 /** 011 * Sorts {@link Resource resources} based on their telescope. 012 * <p> 013 * Because this class is a {@link SortKey}, you may configure its instances with 014 * a particular {@code SortOrder}. Because it is a {@link StringSortKey}, you 015 * may tell it to ignore differences in case. Finally, because it is a 016 * {@link Comparator}, you may use it for sorting collections on its own, or 017 * place it in a {@link edu.nrao.sss.sort.CompoundComparator} to use as one of 018 * many keys in a single sort.</p> 019 * <p/> 020 * The default values for this key's attributes are: 021 * <ul> 022 * <li>{@link #setOrder(SortOrder) Sort order}: 023 * {@link SortOrder#NATURAL natural}</li> 024 * <li>{@link #setIgnoreCase(boolean) Ignore case}: true</li> 025 * </ul> 026 * <p> 027 * <b>Version Info:</b> 028 * <table style="margin-left:2em"> 029 * <tr><td>$Revision: 1710 $</td></tr> 030 * <tr><td>$Date: 2008-11-14 11:54:07 -0700 (Fri, 14 Nov 2008) $</td></tr> 031 * <tr><td>$Author: dharland $</td></tr> 032 * </table></p> 033 */ 034 public class TelescopeSortKey 035 extends StringSortKey 036 implements Comparator<Resource> 037 { 038 public int compare(Resource a, Resource b) 039 { 040 return compareObjects(a.getTelescope().toString(), b.getTelescope().toString()); 041 } 042 }