Пример #1
0
 @Override
 public int compare(ResultModel o1, ResultModel o2) {
   CompareToBuilder builder = new CompareToBuilder();
   builder.append(o1.getScore(), o2.getScore());
   builder.append(o1.getNinerCount(), o2.getNinerCount());
   return builder.toComparison() * -1;
 }
Пример #2
0
 @Override
 public int compareTo(final Entry<T> o) {
   final CompareToBuilder b = new CompareToBuilder();
   b.append(-this.count, -o.count);
   b.append(this.value, o.value);
   return b.toComparison();
 }
Пример #3
0
 public CompareToBuilder append(Object obj, Object obj1, Comparator comparator) {
   while (comparison != 0 || obj == obj1) {
     return this;
   }
   if (obj == null) {
     comparison = -1;
     return this;
   }
   if (obj1 == null) {
     comparison = 1;
     return this;
   }
   if (obj.getClass().isArray()) {
     if (obj instanceof long[]) {
       append((long[]) obj, (long[]) obj1);
       return this;
     }
     if (obj instanceof int[]) {
       append((int[]) obj, (int[]) obj1);
       return this;
     }
     if (obj instanceof short[]) {
       append((short[]) obj, (short[]) obj1);
       return this;
     }
     if (obj instanceof char[]) {
       append((char[]) obj, (char[]) obj1);
       return this;
     }
     if (obj instanceof byte[]) {
       append((byte[]) obj, (byte[]) obj1);
       return this;
     }
     if (obj instanceof double[]) {
       append((double[]) obj, (double[]) obj1);
       return this;
     }
     if (obj instanceof float[]) {
       append((float[]) obj, (float[]) obj1);
       return this;
     }
     if (obj instanceof boolean[]) {
       append((boolean[]) obj, (boolean[]) obj1);
       return this;
     } else {
       append((Object[]) obj, (Object[]) obj1, comparator);
       return this;
     }
   }
   if (comparator == null) {
     comparison = ((Comparable) obj).compareTo(obj1);
     return this;
   } else {
     comparison = comparator.compare(obj, obj1);
     return this;
   }
 }
Пример #4
0
 public CompareToBuilder append(boolean aflag[], boolean aflag1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && aflag != aflag1) {
     if (aflag == null) {
       comparison = i;
       return this;
     }
     if (aflag1 == null) {
       comparison = 1;
       return this;
     }
     if (aflag.length != aflag1.length) {
       if (aflag.length >= aflag1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < aflag.length && comparison == 0) {
       append(aflag[j], aflag1[j]);
       j++;
     }
   }
   return this;
 }
Пример #5
0
 public CompareToBuilder append(short aword0[], short aword1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && aword0 != aword1) {
     if (aword0 == null) {
       comparison = i;
       return this;
     }
     if (aword1 == null) {
       comparison = 1;
       return this;
     }
     if (aword0.length != aword1.length) {
       if (aword0.length >= aword1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < aword0.length && comparison == 0) {
       append(aword0[j], aword1[j]);
       j++;
     }
   }
   return this;
 }
Пример #6
0
 public CompareToBuilder append(Object aobj[], Object aobj1[], Comparator comparator) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_3;
   if (comparison == 0 && aobj != aobj1) {
     if (aobj == null) {
       comparison = i;
       return this;
     }
     if (aobj1 == null) {
       comparison = 1;
       return this;
     }
     if (aobj.length != aobj1.length) {
       if (aobj.length >= aobj1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < aobj.length && comparison == 0) {
       append(aobj[j], aobj1[j], comparator);
       j++;
     }
   }
   return this;
 }
Пример #7
0
 public CompareToBuilder append(long al[], long al1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && al != al1) {
     if (al == null) {
       comparison = i;
       return this;
     }
     if (al1 == null) {
       comparison = 1;
       return this;
     }
     if (al.length != al1.length) {
       if (al.length >= al1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < al.length && comparison == 0) {
       append(al[j], al1[j]);
       j++;
     }
   }
   return this;
 }
Пример #8
0
 public CompareToBuilder append(int ai[], int ai1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && ai != ai1) {
     if (ai == null) {
       comparison = i;
       return this;
     }
     if (ai1 == null) {
       comparison = 1;
       return this;
     }
     if (ai.length != ai1.length) {
       if (ai.length >= ai1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < ai.length && comparison == 0) {
       append(ai[j], ai1[j]);
       j++;
     }
   }
   return this;
 }
Пример #9
0
 public CompareToBuilder append(float af[], float af1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && af != af1) {
     if (af == null) {
       comparison = i;
       return this;
     }
     if (af1 == null) {
       comparison = 1;
       return this;
     }
     if (af.length != af1.length) {
       if (af.length >= af1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < af.length && comparison == 0) {
       append(af[j], af1[j]);
       j++;
     }
   }
   return this;
 }
Пример #10
0
 public CompareToBuilder append(double ad[], double ad1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && ad != ad1) {
     if (ad == null) {
       comparison = i;
       return this;
     }
     if (ad1 == null) {
       comparison = 1;
       return this;
     }
     if (ad.length != ad1.length) {
       if (ad.length >= ad1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < ad.length && comparison == 0) {
       append(ad[j], ad1[j]);
       j++;
     }
   }
   return this;
 }
Пример #11
0
 public CompareToBuilder append(char ac[], char ac1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && ac != ac1) {
     if (ac == null) {
       comparison = i;
       return this;
     }
     if (ac1 == null) {
       comparison = 1;
       return this;
     }
     if (ac.length != ac1.length) {
       if (ac.length >= ac1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < ac.length && comparison == 0) {
       append(ac[j], ac1[j]);
       j++;
     }
   }
   return this;
 }
Пример #12
0
 public CompareToBuilder append(byte abyte0[], byte abyte1[]) {
   int i;
   i = -1;
   break MISSING_BLOCK_LABEL_2;
   if (comparison == 0 && abyte0 != abyte1) {
     if (abyte0 == null) {
       comparison = i;
       return this;
     }
     if (abyte1 == null) {
       comparison = 1;
       return this;
     }
     if (abyte0.length != abyte1.length) {
       if (abyte0.length >= abyte1.length) {
         i = 1;
       }
       comparison = i;
       return this;
     }
     int j = 0;
     while (j < abyte0.length && comparison == 0) {
       append(abyte0[j], abyte1[j]);
       j++;
     }
   }
   return this;
 }
Пример #13
0
 private static void reflectionAppend(
     Object obj,
     Object obj1,
     Class class1,
     CompareToBuilder comparetobuilder,
     boolean flag,
     String as[]) {
   Field afield[] = class1.getDeclaredFields();
   AccessibleObject.setAccessible(afield, true);
   int i = 0;
   do {
     if (i >= afield.length || comparetobuilder.comparison != 0) {
       return;
     }
     Field field = afield[i];
     if (!ArrayUtils.contains(as, field.getName())
         && field.getName().indexOf('$') == -1
         && (flag || !Modifier.isTransient(field.getModifiers()))
         && !Modifier.isStatic(field.getModifiers())) {
       try {
         comparetobuilder.append(field.get(obj), field.get(obj1));
       } catch (IllegalAccessException illegalaccessexception) {
         throw new InternalError("Unexpected IllegalAccessException");
       }
     }
     i++;
   } while (true);
 }
 @Override
 public int compare(RowKey key1, RowKey key2) {
   CompareToBuilder builder = new CompareToBuilder();
   for (String name : sortFields) {
     builder.append(key1.getColumnValue(name), key2.getColumnValue(name));
   }
   return builder.toComparison();
 }
  /* (non-Javadoc)
   * @see java.lang.Comparable#compareTo(java.lang.Object)
   */
  @Override
  public int compareTo(RoutingProcessorConfiguration o) {
    CompareToBuilder builder =
        (new CompareToBuilder())
            .append(getRoutingInstances().size(), o.getRoutingInstances().size());

    if (builder.toComparison() == 0) {
      Iterator<RoutingInstanceConfiguration> lit = getRoutingInstances().iterator();
      Iterator<RoutingInstanceConfiguration> rit = o.getRoutingInstances().iterator();

      while (lit.hasNext()) builder.append(lit.next(), rit.next());
    }

    return builder.toComparison();
  }