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

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

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

Unchecked.runnable介绍

[英]Wrap a CheckedRunnable in a Runnable.

Example: ``

  1. new Thread(Unchecked.runnable(() -> {
  2. throw new Exception("Cannot run this thread");
  3. })).start();

[中]将CheckedRunnable包装成Runnable。
示例:``

  1. new Thread(Unchecked.runnable(() -> {
  2. throw new Exception("Cannot run this thread");
  3. })).start();

代码示例

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

  1. /**
  2. * @see {@link Unchecked#runnable(CheckedRunnable)}
  3. */
  4. static Runnable unchecked(CheckedRunnable runnable) {
  5. return Unchecked.runnable(runnable);
  6. }

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

  1. /**
  2. * @see {@link Unchecked#runnable(CheckedRunnable, Consumer)}
  3. */
  4. static Runnable unchecked(CheckedRunnable runnable, Consumer<Throwable> handler) {
  5. return Unchecked.runnable(runnable, handler);
  6. }
  7. }

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

  1. /**
  2. * @see {@link Unchecked#runnable(CheckedRunnable)}
  3. */
  4. static Runnable unchecked(CheckedRunnable runnable) {
  5. return Unchecked.runnable(runnable);
  6. }

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

  1. /**
  2. * Wrap a {@link CheckedRunnable} in a {@link Runnable}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * new Thread(Unchecked.runnable(() -> {
  7. * throw new Exception("Cannot run this thread");
  8. * })).start();
  9. * </pre></code>
  10. */
  11. public static Runnable runnable(CheckedRunnable runnable) {
  12. return Unchecked.runnable(runnable, Unchecked.RETHROW_ALL);
  13. }

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

  1. /**
  2. * Wrap a {@link CheckedRunnable} in a {@link Runnable}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * new Thread(Unchecked.runnable(() -> {
  7. * throw new Exception("Cannot run this thread");
  8. * })).start();
  9. * </pre></code>
  10. */
  11. public static Runnable runnable(CheckedRunnable runnable) {
  12. return runnable(runnable, THROWABLE_TO_RUNTIME_EXCEPTION);
  13. }

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

  1. /**
  2. * Wrap a {@link CheckedRunnable} in a {@link Runnable}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * new Thread(Unchecked.runnable(() -> {
  7. * throw new Exception("Cannot run this thread");
  8. * })).start();
  9. * </pre></code>
  10. */
  11. public static Runnable runnable(CheckedRunnable runnable) {
  12. return Unchecked.runnable(runnable, Unchecked.RETHROW_ALL);
  13. }

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

  1. /**
  2. * @see {@link Unchecked#runnable(CheckedRunnable, Consumer)}
  3. */
  4. static Runnable unchecked(CheckedRunnable runnable, Consumer<Throwable> handler) {
  5. return Unchecked.runnable(runnable, handler);
  6. }
  7. }

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

  1. /**
  2. * Wrap a {@link CheckedRunnable} in a {@link Runnable}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * new Thread(Unchecked.runnable(() -> {
  7. * throw new Exception("Cannot run this thread");
  8. * })).start();
  9. * </pre></code>
  10. */
  11. public static Runnable runnable(CheckedRunnable runnable) {
  12. return runnable(runnable, THROWABLE_TO_RUNTIME_EXCEPTION);
  13. }

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

  1. /**
  2. * Wrap a <code>Reader</code> into a <code>Seq</code>.
  3. * <p>
  4. * Client code must close the <code>Reader</code>. All
  5. * {@link IOException}'s thrown be the <code>Reader</code> are wrapped
  6. * by {@link UncheckedIOException}'s.
  7. */
  8. static Seq<Character> seq(Reader reader) {
  9. if (reader == null)
  10. return Seq.empty();
  11. FunctionalSpliterator<Character> spliterator = consumer -> {
  12. try {
  13. int value = reader.read();
  14. if (value != -1)
  15. consumer.accept((char) value);
  16. return value != -1;
  17. }
  18. catch (IOException e) {
  19. throw new UncheckedIOException(e);
  20. }
  21. };
  22. return seq(spliterator).onClose(Unchecked.runnable(reader::close));
  23. }

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

  1. /**
  2. * Wrap an <code>InputStream</code> into a <code>Seq</code>.
  3. * <p>
  4. * Client code must close the <code>InputStream</code>. All
  5. * {@link IOException}'s thrown be the <code>InputStream</code> are wrapped
  6. * by {@link UncheckedIOException}'s.
  7. */
  8. static Seq<Byte> seq(InputStream is) {
  9. if (is == null)
  10. return Seq.empty();
  11. FunctionalSpliterator<Byte> spliterator = consumer -> {
  12. try {
  13. int value = is.read();
  14. if (value != -1)
  15. consumer.accept((byte) value);
  16. return value != -1;
  17. }
  18. catch (IOException e) {
  19. throw new UncheckedIOException(e);
  20. }
  21. };
  22. return seq(spliterator).onClose(Unchecked.runnable(is::close));
  23. }

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

  1. /**
  2. * Wrap an <code>InputStream</code> into a <code>Seq</code>.
  3. * <p>
  4. * Client code must close the <code>InputStream</code>. All
  5. * {@link IOException}'s thrown be the <code>InputStream</code> are wrapped
  6. * by {@link UncheckedIOException}'s.
  7. */
  8. static Seq<Byte> seq(InputStream is) {
  9. if (is == null)
  10. return Seq.empty();
  11. FunctionalSpliterator<Byte> spliterator = consumer -> {
  12. try {
  13. int value = is.read();
  14. if (value != -1)
  15. consumer.accept((byte) value);
  16. return value != -1;
  17. }
  18. catch (IOException e) {
  19. throw new UncheckedIOException(e);
  20. }
  21. };
  22. return seq(spliterator).onClose(Unchecked.runnable(is::close));
  23. }

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

  1. /**
  2. * Wrap a <code>Reader</code> into a <code>Seq</code>.
  3. * <p>
  4. * Client code must close the <code>Reader</code>. All
  5. * {@link IOException}'s thrown be the <code>Reader</code> are wrapped
  6. * by {@link UncheckedIOException}'s.
  7. */
  8. static Seq<Character> seq(Reader reader) {
  9. if (reader == null)
  10. return Seq.empty();
  11. FunctionalSpliterator<Character> spliterator = consumer -> {
  12. try {
  13. int value = reader.read();
  14. if (value != -1)
  15. consumer.accept((char) value);
  16. return value != -1;
  17. }
  18. catch (IOException e) {
  19. throw new UncheckedIOException(e);
  20. }
  21. };
  22. return seq(spliterator).onClose(Unchecked.runnable(reader::close));
  23. }

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

  1. public static void main(String[] args) throws Exception {
  2. CMSBootstrap.run(Unchecked.runnable(() -> {
  3. migrate();
  4. codegen();
  5. }));
  6. }
  7. }

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

  1. /**
  2. *
  3. */
  4. @FXML
  5. public void clickRun() {
  6. if (this.ctrlCenter.getProject() != null) {
  7. this.ctrlCenter.checkChanges();
  8. }
  9. final Project project = ProjectIOUtils.loadFrom(this.pathFolder);
  10. if (project != null) {
  11. final Thread thread = new Thread(Unchecked.runnable(() -> project.runAlchemistSimulation(false)), "SingleRunGUI");
  12. thread.setDaemon(true);
  13. thread.start();
  14. } else {
  15. final Alert alert = new Alert(AlertType.ERROR);
  16. alert.setTitle(RESOURCES.getString("error_running"));
  17. alert.setHeaderText(RESOURCES.getString("error_running_header"));
  18. alert.setContentText(RESOURCES.getString("error_running_content"));
  19. alert.showAndWait();
  20. }
  21. }

相关文章