/* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { // TODO Auto-generated method stub if (obj != null && obj instanceof Tag) { Catalog c = (Catalog) obj; if (StringUtils.isNotBlank(c.getName()) && c.getName().equals(this.getName())) { return true; } if (c.getId() != null && c.getId().equals(this.getId())) { return true; } } return false; }
/* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override public int compareTo(Catalog c2) { // TODO Auto-generated method stub // int value = 0; // Long o_1 = this.order; // Long o_2 = c2.getOrder(); // if (o_2 == null || o_1 == null) { // return 0; // } // value = o_1 > o_2 ? -1 : (o_1.equals(o_2) ? 0 : 1); // return value; int flag = 0; if (c2.getOrder() == null && this.getOrder() != null) { flag = -1; } else if (c2.getOrder() != null && this.getOrder() == null) { flag = 1; } else if (c2.getOrder() != null && this.getOrder() != null) { flag = this.getOrder() < c2.getOrder() ? -1 : 1; } else if (c2.getOrder() == null && this.getOrder() == null) { flag = this.getId() < c2.getId() ? 1 : -1; } return flag; }