Exemplo n.º 1
0
  private <T> T first(Iteration<T, ?> iter) throws Exception {
    try {
      if (iter.hasNext()) {
        return iter.next();
      }
    } finally {
      Iterations.closeCloseable(iter);
    }

    return null;
  }
Exemplo n.º 2
0
  private int countElements(Iteration<?, ?> iter) throws Exception {
    int count = 0;

    try {
      while (iter.hasNext()) {
        iter.next();
        count++;
      }
    } finally {
      Iterations.closeCloseable(iter);
    }

    return count;
  }