org.jooq.lambda.Unchecked.intConsumer()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.jooq.lambda.Unchecked.intConsumer()方法的一些代码示例,展示了Unchecked.intConsumer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unchecked.intConsumer()方法的具体详情如下:
包路径:org.jooq.lambda.Unchecked
类名称:Unchecked
方法名:intConsumer

Unchecked.intConsumer介绍

[英]Wrap a CheckedIntConsumer in a IntConsumer.

Example: ``

Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> { 
if (i < 0) 
throw new Exception("Only positive numbers allowed"); 
}));

[中]将CheckedIntConsumer包装在IntConsumer中。
示例:``

Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> { 
if (i < 0) 
throw new Exception("Only positive numbers allowed"); 
}));

代码示例

代码示例来源:origin: org.jooq/jool

/**
 * @see {@link Unchecked#intConsumer(CheckedIntConsumer)}
 */
static IntConsumer unchecked(CheckedIntConsumer consumer) {
  return Unchecked.intConsumer(consumer);
}

代码示例来源:origin: org.jooq/jool

/**
   * @see {@link Unchecked#intConsumer(CheckedIntConsumer, Consumer)}
   */
  static IntConsumer unchecked(CheckedIntConsumer consumer, Consumer<Throwable> handler) {
    return Unchecked.intConsumer(consumer, handler);
  }
}

代码示例来源:origin: org.jooq/jool-java-8

/**
 * @see {@link Unchecked#intConsumer(CheckedIntConsumer)}
 */
static IntConsumer unchecked(CheckedIntConsumer consumer) {
  return Unchecked.intConsumer(consumer);
}

代码示例来源:origin: org.jooq/jool-java-8

/**
   * @see {@link Unchecked#intConsumer(CheckedIntConsumer, Consumer)}
   */
  static IntConsumer unchecked(CheckedIntConsumer consumer, Consumer<Throwable> handler) {
    return Unchecked.intConsumer(consumer, handler);
  }
}

代码示例来源:origin: org.jooq/jool

/**
 * Wrap a {@link CheckedIntConsumer} in a {@link IntConsumer}.
 * <p>
 * Example:
 * <code><pre>
 * Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> {
 *     if (i &lt; 0)
 *         throw new Exception("Only positive numbers allowed");
 * }));
 * </pre></code>
 */
public static IntConsumer intConsumer(CheckedIntConsumer consumer) {
  return intConsumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
}

代码示例来源:origin: org.jooq/jool

/**
 * Wrap a {@link CheckedIntConsumer} in a {@link IntConsumer}.
 * <p>
 * Example:
 * <code><pre>
 * Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> {
 *     if (i &lt; 0)
 *         throw new Exception("Only positive numbers allowed");
 * }));
 * </pre></code>
 */
public static IntConsumer intConsumer(CheckedIntConsumer consumer) {
  return Unchecked.intConsumer(consumer, Unchecked.RETHROW_ALL);
}

代码示例来源:origin: org.jooq/jool-java-8

/**
 * Wrap a {@link CheckedIntConsumer} in a {@link IntConsumer}.
 * <p>
 * Example:
 * <code><pre>
 * Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> {
 *     if (i &lt; 0)
 *         throw new Exception("Only positive numbers allowed");
 * }));
 * </pre></code>
 */
public static IntConsumer intConsumer(CheckedIntConsumer consumer) {
  return Unchecked.intConsumer(consumer, Unchecked.RETHROW_ALL);
}

代码示例来源:origin: org.jooq/jool-java-8

/**
 * Wrap a {@link CheckedIntConsumer} in a {@link IntConsumer}.
 * <p>
 * Example:
 * <code><pre>
 * Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> {
 *     if (i &lt; 0)
 *         throw new Exception("Only positive numbers allowed");
 * }));
 * </pre></code>
 */
public static IntConsumer intConsumer(CheckedIntConsumer consumer) {
  return intConsumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
}

代码示例来源:origin: RankSys/RankSys

/**
 * Saves a PreferenceData instance in two files for user and item preferences, respectively. The format of the user preferences stream consists on one list per line, starting with the identifier of the user followed by the identifier-rating pairs of the items related to that. The item preferences stream follows the same format by swapping the roles of users and items.
 *
 * @param prefData preferences
 * @param uo stream of user preferences
 * @param io stream of user preferences
 */
public void write(FastPreferenceData<?, ?> prefData, OutputStream uo, OutputStream io) {
  BiConsumer<FastPreferenceData<?, ?>, OutputStream> saver = Unchecked.biConsumer((prefs, os) -> {
    try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
      prefs.getUidxWithPreferences().forEach(Unchecked.intConsumer(uidx -> {
        String a = prefs.getUidxPreferences(uidx)
            .sorted((p1, p2) -> Integer.compare(p1.v1, p2.v1))
            .map(p -> p.v1 + "\t" + (int) p.v2)
            .collect(joining("\t"));
        writer.write(uidx + "\t" + a);
        writer.newLine();
      }));
    }
  });
  saver.accept(prefData, uo);
  saver.accept(new TransposedPreferenceData<>(prefData), io);
}

代码示例来源:origin: RankSys/RankSys

/**
 * Saves a PreferenceData instance in two files for user and item preferences, respectively. The format of the user preferences stream consists on one list per line, starting with the identifier of the user followed by the identifiers of the items related to that. The item preferences stream follows the same format by swapping the roles of users and items.
 *
 * @param prefData preferences
 * @param uo stream of user preferences
 * @param io stream of user preferences
 */
public void write(FastPreferenceData<?, ?> prefData, OutputStream uo, OutputStream io) {
  BiConsumer<FastPreferenceData<?, ?>, OutputStream> saver = Unchecked.biConsumer((prefs, os) -> {
    try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
      prefs.getUidxWithPreferences().forEach(Unchecked.intConsumer(uidx -> {
        String a = prefs.getUidxPreferences(uidx)
            .mapToInt(IdxPref::v1)
            .sorted()
            .mapToObj(Integer::toString)
            .collect(joining("\t"));
        writer.write(uidx + "\t" + a);
        writer.newLine();
      }));
    }
  });
  saver.accept(prefData, uo);
  saver.accept(new TransposedPreferenceData<>(prefData), io);
}

相关文章