List of usage examples for java.util Comparator toString
public String toString()
From source file:com.github.olivervbk.sonar.devlistnotification.initiatior.SendNotificationsPostJob.java
private static String getComparatorSymbol(final Comparator comparator) { switch (comparator) { case GT:/*from www . ja v a2 s . co m*/ return ">"; case LT: return "<"; case EQ: return "="; case NE: return "!="; default: return comparator.toString(); } }
From source file:com.redhat.lightblue.JsonNodeBuilder.java
public JsonNodeBuilder add(String key, java.util.Comparator value) { if (include(value)) { root.put(key, value.toString()); }/* w ww.java 2 s . co m*/ return this; }
From source file:com.sm.query.utils.QueryUtils.java
public static boolean compare(Result left, String operator, Result right) { Comparator comparator = getComparator(operator); if (left.getType() == Type.STRING) { if (left.getValue() != null && right.getValue() != null) { String leftValue = (String) left.getValue(); String rightValue = (String) right.getValue(); switch (comparator) { case Equal: return leftValue.equals(rightValue); case NotEqual: return !leftValue.equals(rightValue); case Greater: return (leftValue.compareTo(rightValue) > 0); case GreaterEq: return (leftValue.compareTo(rightValue) >= 0); case Less: return (leftValue.compareTo(rightValue) < 0); case LessEq: return (leftValue.compareTo(rightValue) <= 0); default: throw new QueryException("invalid " + comparator.toString() + " for String"); }//from ww w . j a v a 2s. co m } else if (left.getValue() == null && right.getValue() == null) return true; else return false; } else if (left.getType() == Type.NULL || right.getType() == Type.NULL) { switch (comparator) { case Equal: return (left.getValue() == null && right.getValue() == null); case NotEqual: return !(left.getValue() == null && right.getValue() == null); // return false,instead of exception default: return false; } } else if (left.getType() == Type.BOOLEAN || left.getType() == Type.BOOLEANS) { switch (comparator) { case Equal: return ((Boolean) left.getValue()).equals(((Boolean) right.getValue())); case NotEqual: return !((Boolean) left.getValue()).equals(((Boolean) right.getValue())); default: throw new QueryException("invalid " + comparator.toString() + " for boolean"); } } else { if (isObjectType(left.getType())) throw new QueryException("comparator not for " + left.getType().toString()); else { //this is no number type if (determineType(left, right) == Type.LONG) { long lf = convertLong(left); long rt = convertLong(right); long diff = lf - rt; return deterMineLong(diff, comparator); } else { double lf = convertDouble(left); double rt = convertDouble(right); double diff = lf - rt; return deterMineDouble(diff, comparator); } } } }