Пример #1
0
  private Optional compare(boolean isMax, LambdaExpression le) {
    Object result = null;

    if (iterator.hasNext()) {
      Object obj = iterator.next();
      result = obj;
    }

    while (iterator.hasNext()) {
      Object obj = iterator.next();
      if (isMax
          && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() > 0) {
        result = obj;
      } else if (!isMax
          && ELSupport.coerceToNumber(null, le.invoke(obj, result), Integer.class).intValue() < 0) {
        result = obj;
      }
    }

    if (result == null) {
      return Optional.EMPTY;
    } else {
      return new Optional(result);
    }
  }
Пример #2
0
 @Override
 public int compare(Object o1, Object o2) {
   return ELSupport.coerceToNumber(null, le.invoke(o1, o2), Integer.class).intValue();
 }