/* * IntCompare.java - Integer object comparator. * * Copyright (c) 1998, Charles McManis, All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. * * CHUCK MCMANIS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. CHUCK MCMANIS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ public class IntCompare implements Comparator { public boolean lessThan(Object a, Object b) { return ((Integer) a).intValue() < ((Integer) b).intValue(); } public boolean greaterThan(Object a, Object b) { return ((Integer) a).intValue() > ((Integer) b).intValue(); } public boolean equalTo(Object a, Object b) { return ((Integer) a).intValue() == ((Integer) b).intValue(); } public void typeCheck(Object a) { if (a instanceof Integer) return; throw new RuntimeException("Type violation!"); } }