1 25 26 package com.j2biz.blogunity.util; 27 28 import java.io.Serializable ; 29 import java.util.Comparator ; 30 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 34 import com.j2biz.blogunity.exception.BlogunityRuntimeException; 35 import com.j2biz.blogunity.i18n.I18N; 36 import com.j2biz.blogunity.i18n.I18NStatusFactory; 37 import com.j2biz.blogunity.pojo.Category; 38 39 46 public class CategoryComparator implements Comparator , Serializable { 47 50 private static final long serialVersionUID = 3834594287970301240L; 51 54 private static final Log log = LogFactory.getLog(CategoryComparator.class); 55 56 62 public int compare(Object o1, Object o2) { 63 64 try { 65 Category u1 = (Category) o1; 66 Category u2 = (Category) o2; 67 68 return u1.getName().compareTo(u2.getName()); 69 70 } catch (Exception e) { 71 log.error("compare(Object, Object)", e); 72 throw new BlogunityRuntimeException(I18NStatusFactory.create( 73 I18N.ERRORS.UNABLE_TO_COMPARE, new String []{"categories"}, e)); 74 } 75 76 } 77 78 } | Popular Tags |