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

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

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

Unchecked.function介绍

[英]Wrap a CheckedFunction in a Function.

Example: ``

  1. map.computeIfAbsent("key", Unchecked.function(k -> {
  2. if (k.length() > 10)
  3. throw new Exception("Only short strings allowed");
  4. return 42;
  5. }));

[中]将CheckedFunction包装到函数中。
示例:``

  1. map.computeIfAbsent("key", Unchecked.function(k -> {
  2. if (k.length() > 10)
  3. throw new Exception("Only short strings allowed");
  4. return 42;
  5. }));

代码示例

代码示例来源:origin: apache/storm

  1. /**
  2. * Delete the oldest files in each overloaded worker log dir.
  3. */
  4. @VisibleForTesting
  5. List<DeletionMeta> perWorkerDirCleanup(long size) {
  6. return workerLogs.getAllWorkerDirs().stream()
  7. .map(Unchecked.function(dir ->
  8. directoryCleaner.deleteOldestWhileTooLarge(Collections.singletonList(dir), size, true, null)))
  9. .collect(toList());
  10. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public void list(String path, Consumer<FTPFile> consumer) {
  3. doExecute(Unchecked.function(client -> {
  4. Arrays.stream(client.listFiles(path)).forEach(consumer);
  5. return null;
  6. }));
  7. }
  8. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public boolean upload(String fileName, String text) {
  3. return doExecute(Unchecked.function(client -> {
  4. try (ByteArrayInputStream inputStream = new ByteArrayInputStream(text.getBytes())) {
  5. return client.storeFile(fileName, inputStream);
  6. }
  7. }));
  8. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public boolean download(String fileName, OutputStream outputStream) {
  3. return doExecute(Unchecked.function(client -> client.retrieveFile(fileName, outputStream)));
  4. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public boolean delete(String fileName) {
  3. return doExecute(Unchecked.function(client -> client.deleteFile(fileName)));
  4. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public boolean rename(String from, String to) {
  3. return doExecute(Unchecked.function(client -> client.rename(from, to)));
  4. }

代码示例来源:origin: hs-web/hsweb-framework

  1. @Override
  2. public boolean upload(String fileName, InputStream input) {
  3. return doExecute(Unchecked.function(client -> client.storeFile(fileName, input)));
  4. }

代码示例来源:origin: apache/storm

  1. try {
  2. logFiles = Arrays.stream(topoDir.listFiles())
  3. .flatMap(Unchecked.function(portDir -> directoryCleaner.getFilesForDir(portDir).stream()))
  4. .filter(File::isFile)
  5. .collect(toCollection(TreeSet::new));

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

  1. /**
  2. * @see {@link Unchecked#function(CheckedFunction, Consumer)}
  3. */
  4. static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function, Consumer<Throwable> handler) {
  5. return Unchecked.function(function, handler);
  6. }
  7. }

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

  1. /**
  2. * @see {@link Unchecked#function(CheckedFunction)}
  3. */
  4. static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function) {
  5. return Unchecked.function(function);
  6. }

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

  1. /**
  2. * @see {@link Unchecked#function(CheckedFunction)}
  3. */
  4. static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function) {
  5. return Unchecked.function(function);
  6. }

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

  1. /**
  2. * @see {@link Unchecked#function(CheckedFunction, Consumer)}
  3. */
  4. static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function, Consumer<Throwable> handler) {
  5. return Unchecked.function(function, handler);
  6. }
  7. }

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

  1. /**
  2. * Wrap a {@link CheckedFunction} in a {@link Function}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * map.computeIfAbsent("key", Unchecked.function(k -> {
  7. * if (k.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. *
  10. * return 42;
  11. * }));
  12. * </pre></code>
  13. */
  14. public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
  15. return function(function, THROWABLE_TO_RUNTIME_EXCEPTION);
  16. }

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

  1. /**
  2. * Wrap a {@link CheckedFunction} in a {@link Function}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * map.computeIfAbsent("key", Unchecked.function(k -> {
  7. * if (k.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. *
  10. * return 42;
  11. * }));
  12. * </pre></code>
  13. */
  14. public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
  15. return function(function, THROWABLE_TO_RUNTIME_EXCEPTION);
  16. }

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

  1. /**
  2. * Wrap a {@link CheckedFunction} in a {@link Function}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * map.computeIfAbsent("key", Unchecked.function(k -> {
  7. * if (k.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. *
  10. * return 42;
  11. * }));
  12. * </pre></code>
  13. */
  14. public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
  15. return Unchecked.function(function, Unchecked.RETHROW_ALL);
  16. }

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

  1. /**
  2. * Wrap a {@link CheckedFunction} in a {@link Function}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * map.computeIfAbsent("key", Unchecked.function(k -> {
  7. * if (k.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. *
  10. * return 42;
  11. * }));
  12. * </pre></code>
  13. */
  14. public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
  15. return Unchecked.function(function, Unchecked.RETHROW_ALL);
  16. }

代码示例来源:origin: hortonworks/streamline

  1. List<CatalogResourceUtil.TopologyDashboardResponse> responses = ParallelStreamUtil.execute(() ->
  2. topologies.parallelStream()
  3. .map(Unchecked.function(t ->
  4. managedTransaction.executeFunction(() ->
  5. CatalogResourceUtil.enrichTopology(t, asUser, latencyTopN,

代码示例来源:origin: hortonworks/streamline

  1. .map(Unchecked.function(s -> {
  2. ComponentMetricSummary overviewMetric;
  3. TopologyTimeSeriesMetrics.TimeSeriesComponentMetric currentMetric = metricsService.getComponentStats(topology, s, from, to, asUser);

相关文章