本文整理了Java中software.amazon.awssdk.utils.FunctionalUtils
类的一些代码示例,展示了FunctionalUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FunctionalUtils
类的具体详情如下:
包路径:software.amazon.awssdk.utils.FunctionalUtils
类名称:FunctionalUtils
FunctionalUtils介绍
暂无
代码示例
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public void close() {
runAndLogError(log, "Unable to close channel pools", pools::close);
runAndLogError(log, "Unable to shutdown event loop", sdkEventLoopGroup.eventLoopGroup()::shutdownGracefully);
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* Returns the deserialized object from the given json string and target
* class; or null if the given json string is null.
*/
public static T fromJsonString(String json, Class clazz) {
if (json == null) {
return null;
}
return invokeSafely(() -> OBJECT_MAPPER.readValue(json, clazz));
}
代码示例来源:origin: software.amazon.awssdk/sdk-core
@Override
public CompletableFuture execute(CompletableFuture inputFuture, RequestExecutionContext context)
throws Exception {
return inputFuture.thenApply(safeFunction(input -> delegate.execute(input, context)));
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* A wrapper around a Runnable that throws a checked exception.
*
* @param unsafeRunnable Something that acts like a Runnable but throws an exception
* @return A Runnable that is wrapped in a try-catch converting the checked exception into a runtime exception
*/
public static Runnable safeRunnable(UnsafeRunnable unsafeRunnable) {
return () -> {
try {
unsafeRunnable.run();
} catch (Exception e) {
throw asRuntimeException(e);
}
};
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* A wrapper around a Consumer that throws a checked exception.
*
* @param unsafeConsumer - something that acts like a consumer but throws an exception
* @return a consumer that is wrapped in a try-catch converting the checked exception into a runtime exception
*/
public static Consumer safeConsumer(UnsafeConsumer unsafeConsumer) {
return (input) -> {
try {
unsafeConsumer.accept(input);
} catch (Exception e) {
throw asRuntimeException(e);
}
};
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* Encode a string according to RFC 1630: encoding for form data.
*/
public static String formDataEncode(String value) {
return value == null ? null : invokeSafely(() -> URLEncoder.encode(value, DEFAULT_ENCODING));
}
代码示例来源:origin: software.amazon.awssdk/netty-nio-client
@Override
public void close() {
runAndLogError(log, "Unable to close channel pools", pools::close);
runAndLogError(log, "Unable to shutdown event loop", sdkEventLoopGroup.eventLoopGroup()::shutdownGracefully);
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
protected List createTasks() throws Exception {
return model.getPaginators().entrySet().stream()
.filter(entry -> entry.getValue().isValid())
.flatMap(safeFunction(this::createSyncAndAsyncTasks))
.collect(Collectors.toList());
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* A wrapper around a BiConsumer that throws a checked exception.
*
* @param unsafeSupplier - something that acts like a BiConsumer but throws an exception
* @return a consumer that is wrapped in a try-catch converting the checked exception into a runtime exception
*/
public static Supplier safeSupplier(UnsafeSupplier unsafeSupplier) {
return () -> {
try {
return unsafeSupplier.get();
} catch (Exception e) {
throw asRuntimeException(e);
}
};
}
代码示例来源:origin: software.amazon.awssdk/utils
/**
* Encode a string according to RFC 1630: encoding for form data.
*/
public static String formDataEncode(String value) {
return value == null ? null : invokeSafely(() -> URLEncoder.encode(value, DEFAULT_ENCODING));
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* Called when all events have been delivered to the downstream subscriber.
*/
private void onEventComplete() {
synchronized (this) {
// No op if it's already done
if (isDone) {
return;
}
isDOne= true;
runAndLogError(log, "Error thrown from Subscriber#onComplete, ignoring.",
() -> subscriberRef.get().onComplete());
eventStreamResponseHandler.complete();
future.complete(null);
}
}
代码示例来源:origin: software.amazon.awssdk/codegen
@Override
protected List createTasks() throws Exception {
return model.getPaginators().entrySet().stream()
.filter(entry -> entry.getValue().isValid())
.flatMap(safeFunction(this::createSyncAndAsyncTasks))
.collect(Collectors.toList());
}
代码示例来源:origin: software.amazon.awssdk/utils
/**
* A wrapper around a BiConsumer that throws a checked exception.
*
* @param unsafeSupplier - something that acts like a BiConsumer but throws an exception
* @return a consumer that is wrapped in a try-catch converting the checked exception into a runtime exception
*/
public static Supplier safeSupplier(UnsafeSupplier unsafeSupplier) {
return () -> {
try {
return unsafeSupplier.get();
} catch (Exception e) {
throw asRuntimeException(e);
}
};
}
代码示例来源:origin: software.amazon.awssdk/sdk-core
@Override
public void exceptionOccurred(Throwable throwable) {
try {
invokeSafely(fileChannel::close);
} finally {
invokeSafely(() -> Files.deleteIfExists(path));
}
cf.completeExceptionally(throwable);
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public void exceptionOccurred(Throwable throwable) {
synchronized (this) {
if (!isDone) {
isDOne= true;
// If we have a Subscriber at this point notify it as well
if (subscriberRef.get() != null && shouldSurfaceErrorToEventSubscriber(throwable)) {
runAndLogError(log, "Error thrown from Subscriber#onError, ignoring.",
() -> subscriberRef.get().onError(throwable));
}
eventStreamResponseHandler.exceptionOccurred(throwable);
transformFuture.completeExceptionally(throwable);
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
protected List createTasks() {
info("Emitting marshaller classes");
return model.getShapes().entrySet().stream()
.filter(e -> shouldGenerate(e.getValue()))
.flatMap(safeFunction(e -> createTask(e.getKey(), e.getValue())))
.collect(Collectors.toList());
}
代码示例来源:origin: software.amazon.awssdk/utils
/**
* A wrapper around a Runnable that throws a checked exception.
*
* @param unsafeRunnable Something that acts like a Runnable but throws an exception
* @return A Runnable that is wrapped in a try-catch converting the checked exception into a runtime exception
*/
public static Runnable safeRunnable(UnsafeRunnable unsafeRunnable) {
return () -> {
try {
unsafeRunnable.run();
} catch (Exception e) {
throw asRuntimeException(e);
}
};
}
代码示例来源:origin: software.amazon.awssdk/test-utils
/**
* Returns the deserialized object from the given json string and target
* class; or null if the given json string is null.
*/
public static T fromJsonString(String json, Class clazz) {
if (json == null) {
return null;
}
return invokeSafely(() -> OBJECT_MAPPER.readValue(json, clazz));
}
代码示例来源:origin: aws/aws-sdk-java-v2
.withInput(getObjectTorrentRequest), asyncResponseTransformer);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
() -> asyncResponseTransformer.exceptionOccurred(t));
return CompletableFutureUtils.failedFuture(t);
代码示例来源:origin: software.amazon.awssdk/codegen
@Override
protected List createTasks() {
info("Emitting marshaller classes");
return model.getShapes().entrySet().stream()
.filter(e -> shouldGenerate(e.getValue()))
.flatMap(safeFunction(e -> createTask(e.getKey(), e.getValue())))
.collect(Collectors.toList());
}