Beispiel #1
0
  public static Explain<Integer> getPressedNumber(Integer keyCode) {
    List<Function<Integer, Explain<Integer>>> preds =
        Arrays.asList(
            Explain.mkPred(k -> k >= '0' && k <= '9', k -> k - '0'),
            Explain.mkPred(k -> k >= K.VK_NUMPAD0 && k <= K.VK_NUMPAD9, k -> k - K.VK_NUMPAD0),
            Explain.mkPred(k -> k >= K.VK_F10 && k <= K.VK_F12, k -> k - K.VK_F1 + 1));

    return preds.stream().anyMatch(pr -> pr.apply(keyCode).isSuccess())
        ? preds.stream().map(pr -> pr.apply(keyCode)).filter(e -> e.isSuccess()).findAny().get()
        : new Explain<>(false, "No Number With Such Keycode! " + keyCode);
  }
Beispiel #2
0
  public <T> T eachNode(ReadChildrenEach<T> readJob) {
    DBCursor cursor = null;
    try {
      cursor = collection.find(filters(), fields(), skip, offset).sort(orderBy).limit(offset);
      if (this.hint != null) cursor.hint(hint);
      else if (this.hintIndexName != null) cursor.hint(hintIndexName);

      session.attribute(Explain.class.getCanonicalName(), Explain.create(cursor.explain()));
      ReadChildrenIterator citer = ReadChildrenIterator.create(session, cursor);
      T result = readJob.handle(citer);
      return result;
    } finally {
      IOUtil.close(cursor);
    }
  }