示例#1
0
  // TODO 目前Condition的多个Key是乱序的,是否要排序?
  public static void contidionToString(StringBuilder sb, Map<String, MatchPair> condition) {
    boolean isFirst = true;
    for (Entry<String, MatchPair> entry : condition.entrySet()) {
      String keyName = entry.getKey();
      MatchPair p = entry.getValue();

      @SuppressWarnings("unchecked")
      Set<String>[] setArray = new Set[] {p.matches, p.unmatches};
      String[] opArray = {" = ", " != "};

      for (int i = 0; i < setArray.length; ++i) {
        if (setArray[i].isEmpty()) {
          continue;
        }
        if (isFirst) {
          isFirst = false;
        } else {
          sb.append(" & ");
        }

        sb.append(keyName);
        sb.append(opArray[i]);
        join(sb, setArray[i]);
      }
    }
  }
示例#2
0
 // FIXME 去掉这样的方法调用
 public static String join(Set<String> valueSet) {
   StringBuilder sb = new StringBuilder(128);
   join(sb, valueSet);
   return sb.toString();
 }