Ejemplo n.º 1
0
        @Override
        public int compare(Relation r1, Relation r2) {
          // TODO This doesn't work correctly with formatHooks

          TaggingPreset preset1 =
              TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r1);
          TaggingPreset preset2 =
              TaggingPresetNameTemplateList.getInstance().findPresetTemplate(r2);

          if (preset1 != null || preset2 != null) {
            StringBuilder name1 = new StringBuilder();
            formatRelationNameAndType(r1, name1, preset1);
            StringBuilder name2 = new StringBuilder();
            formatRelationNameAndType(r2, name2, preset2);

            int comp = name1.toString().compareTo(name2.toString());
            if (comp != 0) return comp;
          } else {

            String type1 = getRelationTypeName(r1);
            String type2 = getRelationTypeName(r2);

            int comp = ALPHANUM_COMPARATOR.compare(type1, type2);
            if (comp != 0) return comp;

            String name1 = getRelationName(r1);
            String name2 = getRelationName(r2);

            comp = ALPHANUM_COMPARATOR.compare(name1, name2);
            if (comp != 0) return comp;
          }

          if (r1.getMembersCount() != r2.getMembersCount())
            return (r1.getMembersCount() > r2.getMembersCount()) ? 1 : -1;

          int comp =
              Boolean.valueOf(r1.hasIncompleteMembers())
                  .compareTo(Boolean.valueOf(r2.hasIncompleteMembers()));
          if (comp != 0) return comp;

          if (r1.getUniqueId() > r2.getUniqueId()) return 1;
          else if (r1.getUniqueId() < r2.getUniqueId()) return -1;
          else return 0;
        }
Ejemplo n.º 2
0
  @Override
  public int compareTo(TestError o) {
    if (equals(o)) return 0;

    MultipleNameVisitor v1 = new MultipleNameVisitor();
    MultipleNameVisitor v2 = new MultipleNameVisitor();

    v1.visit(getPrimitives());
    v2.visit(o.getPrimitives());
    return AlphanumComparator.getInstance().compare(v1.toString(), v2.toString());
  }