List of usage examples for com.google.common.collect ComparisonChain result
public abstract int result();
From source file:com.bj58.oceanus.core.jdbc.result.RowSetComparator.java
@Override public int compare(RowSet o1, RowSet o2) { ComparisonChain chain = ComparisonChain.start(); try {//w w w . j a v a 2s .c o m for (int i = 0; i < sortedColumns.length; i++) { TableColumn column = sortedColumns[i]; OrderByType orderByType = column.getOrderByType(); Object target1 = o1.getObject(column.getResultIndex()); Object target2 = o2.getObject(column.getResultIndex()); if (target1 == null) {// nullstring? target1 = ""; if (target2 != null) { target2 = target2.toString(); } else { target2 = ""; } } else if (target2 == null) { target2 = ""; target1 = target1.toString(); } if (orderByType == null || orderByType == OrderByType.ASC) { chain = chain.compare((Comparable<?>) target1, (Comparable<?>) target2); } else { chain = chain.compare((Comparable<?>) target2, (Comparable<?>) target1); } } } catch (Exception e) { throw new ShardException("compare error!row=" + this, e); } return chain.result(); }