本文整理了Java中org.jooq.lambda.Unchecked.function()
方法的一些代码示例,展示了Unchecked.function()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unchecked.function()
方法的具体详情如下:
包路径:org.jooq.lambda.Unchecked
类名称:Unchecked
方法名:function
[英]Wrap a CheckedFunction in a Function.
Example: ``
map.computeIfAbsent("key", Unchecked.function(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42;
}));
[中]将CheckedFunction包装到函数中。
示例:``
map.computeIfAbsent("key", Unchecked.function(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42;
}));
代码示例来源:origin: apache/storm
/**
* Delete the oldest files in each overloaded worker log dir.
*/
@VisibleForTesting
List<DeletionMeta> perWorkerDirCleanup(long size) {
return workerLogs.getAllWorkerDirs().stream()
.map(Unchecked.function(dir ->
directoryCleaner.deleteOldestWhileTooLarge(Collections.singletonList(dir), size, true, null)))
.collect(toList());
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public void list(String path, Consumer<FTPFile> consumer) {
doExecute(Unchecked.function(client -> {
Arrays.stream(client.listFiles(path)).forEach(consumer);
return null;
}));
}
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean upload(String fileName, String text) {
return doExecute(Unchecked.function(client -> {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(text.getBytes())) {
return client.storeFile(fileName, inputStream);
}
}));
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean download(String fileName, OutputStream outputStream) {
return doExecute(Unchecked.function(client -> client.retrieveFile(fileName, outputStream)));
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean delete(String fileName) {
return doExecute(Unchecked.function(client -> client.deleteFile(fileName)));
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean rename(String from, String to) {
return doExecute(Unchecked.function(client -> client.rename(from, to)));
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean upload(String fileName, InputStream input) {
return doExecute(Unchecked.function(client -> client.storeFile(fileName, input)));
}
代码示例来源:origin: apache/storm
try {
logFiles = Arrays.stream(topoDir.listFiles())
.flatMap(Unchecked.function(portDir -> directoryCleaner.getFilesForDir(portDir).stream()))
.filter(File::isFile)
.collect(toCollection(TreeSet::new));
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#function(CheckedFunction, Consumer)}
*/
static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function, Consumer<Throwable> handler) {
return Unchecked.function(function, handler);
}
}
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#function(CheckedFunction)}
*/
static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function) {
return Unchecked.function(function);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#function(CheckedFunction)}
*/
static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function) {
return Unchecked.function(function);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#function(CheckedFunction, Consumer)}
*/
static <T, R> Function<T, R> unchecked(CheckedFunction<T, R> function, Consumer<Throwable> handler) {
return Unchecked.function(function, handler);
}
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedFunction} in a {@link Function}.
* <p>
* Example:
* <code><pre>
* map.computeIfAbsent("key", Unchecked.function(k -> {
* if (k.length() > 10)
* throw new Exception("Only short strings allowed");
*
* return 42;
* }));
* </pre></code>
*/
public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
return function(function, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedFunction} in a {@link Function}.
* <p>
* Example:
* <code><pre>
* map.computeIfAbsent("key", Unchecked.function(k -> {
* if (k.length() > 10)
* throw new Exception("Only short strings allowed");
*
* return 42;
* }));
* </pre></code>
*/
public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
return function(function, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedFunction} in a {@link Function}.
* <p>
* Example:
* <code><pre>
* map.computeIfAbsent("key", Unchecked.function(k -> {
* if (k.length() > 10)
* throw new Exception("Only short strings allowed");
*
* return 42;
* }));
* </pre></code>
*/
public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
return Unchecked.function(function, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedFunction} in a {@link Function}.
* <p>
* Example:
* <code><pre>
* map.computeIfAbsent("key", Unchecked.function(k -> {
* if (k.length() > 10)
* throw new Exception("Only short strings allowed");
*
* return 42;
* }));
* </pre></code>
*/
public static <T, R> Function<T, R> function(CheckedFunction<T, R> function) {
return Unchecked.function(function, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: hortonworks/streamline
List<CatalogResourceUtil.TopologyDashboardResponse> responses = ParallelStreamUtil.execute(() ->
topologies.parallelStream()
.map(Unchecked.function(t ->
managedTransaction.executeFunction(() ->
CatalogResourceUtil.enrichTopology(t, asUser, latencyTopN,
代码示例来源:origin: hortonworks/streamline
.map(Unchecked.function(s -> {
ComponentMetricSummary overviewMetric;
TopologyTimeSeriesMetrics.TimeSeriesComponentMetric currentMetric = metricsService.getComponentStats(topology, s, from, to, asUser);
内容来源于网络,如有侵权,请联系作者删除!