本文整理了Java中org.jooq.lambda.Unchecked.supplier()
方法的一些代码示例,展示了Unchecked.supplier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unchecked.supplier()
方法的具体详情如下:
包路径:org.jooq.lambda.Unchecked
类名称:Unchecked
方法名:supplier
[英]Wrap a CheckedSupplier in a Supplier.
Example: ``
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
[中]将选中的供应商包装在供应商中。
示例:``
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#supplier(CheckedSupplier, Consumer)}
*/
static <T> Supplier<T> unchecked(CheckedSupplier<T> supplier, Consumer<Throwable> handler) {
return Unchecked.supplier(supplier, handler);
}
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedSupplier} in a {@link Supplier}.
* <p>
* Example:
* <code><pre>
* ResultSet rs = statement.executeQuery();
* Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
* </pre></code>
*/
public static <T> Supplier<T> supplier(CheckedSupplier<T> supplier) {
return supplier(supplier, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedSupplier} in a {@link Supplier}.
* <p>
* Example:
* <code><pre>
* ResultSet rs = statement.executeQuery();
* Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
* </pre></code>
*/
public static <T> Supplier<T> supplier(CheckedSupplier<T> supplier) {
return Unchecked.supplier(supplier, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#supplier(CheckedSupplier)}
*/
static <T> Supplier<T> unchecked(CheckedSupplier<T> supplier) {
return Unchecked.supplier(supplier);
}
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#supplier(CheckedSupplier, Consumer)}
*/
static <T> Supplier<T> unchecked(CheckedSupplier<T> supplier, Consumer<Throwable> handler) {
return Unchecked.supplier(supplier, handler);
}
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#supplier(CheckedSupplier)}
*/
static <T> Supplier<T> unchecked(CheckedSupplier<T> supplier) {
return Unchecked.supplier(supplier);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedSupplier} in a {@link Supplier}.
* <p>
* Example:
* <code><pre>
* ResultSet rs = statement.executeQuery();
* Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
* </pre></code>
*/
public static <T> Supplier<T> supplier(CheckedSupplier<T> supplier) {
return Unchecked.supplier(supplier, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedSupplier} in a {@link Supplier}.
* <p>
* Example:
* <code><pre>
* ResultSet rs = statement.executeQuery();
* Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
* </pre></code>
*/
public static <T> Supplier<T> supplier(CheckedSupplier<T> supplier) {
return supplier(supplier, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: StubbornJava/StubbornJava
private static void request(OkHttpClient client, String url) {
Request request = new Request.Builder()
.url(url)
.get()
.build();
Unchecked.supplier(() -> {
Response response = client.newCall(request).execute();
log.debug("{} - {}", response.code(), response.body().string());
return null;
}).get();
}
// {{end:request}}
代码示例来源:origin: StubbornJava/StubbornJava
public List<User> listUsers() {
HttpUrl route = HttpUrl.parse(host + "/users");
Request request = new Request.Builder().url(route).get().build();
return Unchecked.supplier(() -> {
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
List<User> users = Json.serializer().fromInputStream(response.body().byteStream(), User.listTypeRef());
return users;
}
throw HttpClient.unknownException(response);
}
}).get();
}
// {{end:listUsers}}
代码示例来源:origin: StubbornJava/StubbornJava
public void putInputStream(String bucket, String key, InputStream inputStream) {
// This can blow up on large files but that's ok for now.
byte[] bytes = Unchecked.supplier(() -> IOUtils.toByteArray(inputStream)).get();
putBytes(bucket, key, bytes);
}
代码示例来源:origin: org.apereo.cas/cas-server-core-tickets-api
/**
* Deserialize ticket.
*
* @param ticketContent the ticket id
* @param type the type
* @return the ticket instance.
*/
@SneakyThrows
public static Ticket deserializeTicket(final String ticketContent, final String type) {
if (StringUtils.isBlank(type)) {
throw new InvalidTicketException("Invalid ticket type [blank] specified");
}
val clazz = FunctionUtils.doIf(TICKET_TYPE_CACHE.containsKey(type),
() -> TICKET_TYPE_CACHE.get(type),
Unchecked.supplier(() -> {
val clz = Class.forName(type);
TICKET_TYPE_CACHE.put(type, clz);
return clz;
}))
.get();
return deserializeTicket(ticketContent, (Class) clazz);
}
代码示例来源:origin: StubbornJava/StubbornJava
public User createUser(User inputUser) {
HttpUrl route = HttpUrl.parse(host + "/users");
Request request = new Request.Builder()
.url(route)
.post(RequestBodies.jsonObj(inputUser))
.build();
return Unchecked.supplier(() -> {
try (Response response = client.newCall(request).execute()) {
if (response.code() == StatusCodes.CREATED) {
User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
return user;
}
if (response.code() == StatusCodes.BAD_REQUEST) {
return null;
}
throw HttpClient.unknownException(response);
}
}).get();
}
// {{end:createUser}}
代码示例来源:origin: StubbornJava/StubbornJava
public User getUserByEmail(String email) {
HttpUrl route = HttpUrl.parse(host + "/users")
.newBuilder()
.addPathSegment(email)
.build();
Request request = new Request.Builder().url(route).get().build();
return Unchecked.supplier(() -> {
try (Response response = client.newCall(request).execute()) {
// The user exists
if (response.isSuccessful()) {
User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
return user;
}
/*
* 404 Not Found - Either return null or throw your own exception.
* We prefer nulls.
*/
if (response.code() == StatusCodes.NOT_FOUND) {
return null;
}
throw HttpClient.unknownException(response);
}
}).get();
}
// {{end:getUserByEmail}}
代码示例来源:origin: StubbornJava/StubbornJava
public User updateUser(User inputUser) {
HttpUrl route = HttpUrl.parse(host + "/users");
Request request = new Request.Builder()
.url(route)
.put(RequestBodies.jsonObj(inputUser))
.build();
return Unchecked.supplier(() -> {
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
User user = Json.serializer().fromInputStream(response.body().byteStream(), User.typeRef());
return user;
}
if (response.code() == StatusCodes.NOT_FOUND) {
return null;
}
throw HttpClient.unknownException(response);
}
}).get();
}
// {{end:updateUser}}
代码示例来源:origin: org.apereo.cas/cas-server-core-services-api
return Boolean.FALSE;
return Unchecked.supplier(() -> {
for (var i = 1; i <= TOKEN_COUNT_DURATION; i++) {
p.nextToken();
代码示例来源:origin: org.apereo.cas/cas-server-support-wsfederation
Unchecked.supplier(() -> {
LOGGER.debug("Encryption private key is an encrypted keypair");
val ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
return converter.getKeyPair(ckp.decryptKeyPair(decProv));
}),
Unchecked.supplier(() -> {
LOGGER.debug("Extracting a keypair from the private key");
return converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
代码示例来源:origin: RankSys/RankSys
recMap.put("lda", Unchecked.supplier(() -> {
int k = 50;
double alpha = 1.0;
recMap.put("fm-bpr", Unchecked.supplier(() -> {
recMap.put("fm-rmse", Unchecked.supplier(() -> {
内容来源于网络,如有侵权,请联系作者删除!