001 package market.swing; 002 003 import java.io.Serializable; 004 import java.util.Comparator; 005 006 import market.CIOpenPurchaseOrders; 007 008 /** 009 * Compares {@link market.CIOpenPurchaseOrders} by their stocks' values 010 */ 011 public class CmpOpoNumbers implements Comparator<Object>, Serializable { 012 013 /** 014 * ID for serialization. 015 */ 016 private static final long serialVersionUID = -3472688841221897540L; 017 018 /** 019 * The actual comparison. 020 * @param o1 the first CIOpenPurchaseOrder. 021 * @param o2 the second CIOpenPurchaseOrder. 022 * @return an int representing the result of the comparison. 023 */ 024 public int compare(Object o1, Object o2) { 025 CIOpenPurchaseOrders c1 = (CIOpenPurchaseOrders)o1; 026 CIOpenPurchaseOrders c2 = (CIOpenPurchaseOrders)o2; 027 return c1.getOrdersValue().compareTo(c2.getOrdersValue()); 028 } 029 }