本文整理了Java中org.jooq.lambda.Unchecked.consumer()
方法的一些代码示例,展示了Unchecked.consumer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unchecked.consumer()
方法的具体详情如下:
包路径:org.jooq.lambda.Unchecked
类名称:Unchecked
方法名:consumer
[英]Wrap a CheckedConsumer in a Consumer.
Example: ``
Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
if (s.length() > 10)
throw new Exception("Only short strings allowed");
}));
[中]将选中的消费者包装到消费者中。
示例:``
Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
if (s.length() > 10)
throw new Exception("Only short strings allowed");
}));
代码示例来源:origin: apache/storm
dataAndExpected.add(new Tuple3<>(13, 12, null));
dataAndExpected.forEach(Unchecked.consumer(data -> {
Map<String, Object> result = handler.substringSearch(file, pattern, data.v1());
assertEquals(data.v3(), result.get("nextByteOffset"));
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#consumer(CheckedConsumer)}
*/
static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer) {
return Unchecked.consumer(consumer);
}
代码示例来源:origin: org.jooq/jool
/**
* @see {@link Unchecked#consumer(CheckedConsumer, Consumer)}
*/
static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer, Consumer<Throwable> handler) {
return Unchecked.consumer(consumer, handler);
}
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#consumer(CheckedConsumer, Consumer)}
*/
static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer, Consumer<Throwable> handler) {
return Unchecked.consumer(consumer, handler);
}
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* @see {@link Unchecked#consumer(CheckedConsumer)}
*/
static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer) {
return Unchecked.consumer(consumer);
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedConsumer} in a {@link Consumer}.
* <p>
* Example:
* <code><pre>
* Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
* if (s.length() > 10)
* throw new Exception("Only short strings allowed");
* }));
* </pre></code>
*/
public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
return Unchecked.consumer(consumer, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: org.jooq/jool
/**
* Wrap a {@link CheckedConsumer} in a {@link Consumer}.
* <p>
* Example:
* <code><pre>
* Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
* if (s.length() > 10)
* throw new Exception("Only short strings allowed");
* }));
* </pre></code>
*/
public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
return consumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedConsumer} in a {@link Consumer}.
* <p>
* Example:
* <code><pre>
* Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
* if (s.length() > 10)
* throw new Exception("Only short strings allowed");
* }));
* </pre></code>
*/
public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
return consumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
}
代码示例来源:origin: org.jooq/jool-java-8
/**
* Wrap a {@link CheckedConsumer} in a {@link Consumer}.
* <p>
* Example:
* <code><pre>
* Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
* if (s.length() > 10)
* throw new Exception("Only short strings allowed");
* }));
* </pre></code>
*/
public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
return Unchecked.consumer(consumer, Unchecked.RETHROW_ALL);
}
代码示例来源:origin: it.unibo.alchemist/alchemist-projectview
private void copyRecursively(final String path) {
resourcesFrom(path, Integer.MAX_VALUE)
.sorted((s1, s2) -> Integer.compare(s2.length(), s1.length())) // Longest first
.forEach(Unchecked.consumer(p -> {
try (InputStream is = NewProjLayoutSelectController.class.getResourceAsStream(path + '/' + p)) {
final File destination = new File(folderPath + '/' + p);
if (!destination.exists()) {
FileUtils.copyInputStreamToFile(is, destination);
}
}
}));
}
代码示例来源:origin: hortonworks/streamline
ServiceConfigurationInformation(List<ServiceConfiguration> serviceConfigurations) {
this.serviceConfigurations = serviceConfigurations;
this.flattenConfiguration = new HashMap<>();
serviceConfigurations.forEach(Unchecked.consumer(sc -> flattenConfiguration.putAll(sc.getConfigurationMap())));
}
代码示例来源:origin: org.apereo.cas/cas-server-support-x509-core
@Override
public void serialize(final X509CertificateCredential value,
final JsonGenerator generator, final SerializerProvider serializerProvider)
throws IOException {
generator.writeArrayFieldStart("certificates");
Arrays.stream(value.getCertificates()).forEach(Unchecked.consumer(c -> generator.writeBinary(c.getEncoded())));
generator.writeEndArray();
}
代码示例来源:origin: org.apereo.cas/cas-mgmt-core-authz
private void watchResource(final Resource usersFile) {
try (
val watcher = new FileWatcherService(usersFile.getFile(),
Unchecked.consumer(file -> loadResource(usersFile)))) {
watcher.start(getClass().getSimpleName());
} catch (final Exception e) {
LOGGER.debug(e.getMessage(), e);
}
}
代码示例来源:origin: org.apereo.cas/cas-mgmt-core-authz
private void watchResource(final Resource usersFile) {
try (
val watcher = new FileWatcherService(usersFile.getFile(),
Unchecked.consumer(file -> {
val newProps = new Properties();
val input = Files.newInputStream(file.toPath());
newProps.load(input);
input.close();
this.generator = new SpringSecurityPropertiesAuthorizationGenerator(newProps);
}))) {
watcher.start(getClass().getSimpleName());
} catch (final Exception e) {
LOGGER.debug(e.getMessage(), e);
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-wsfederation
public void initialize() {
this.signingCertificateResources.forEach(Unchecked.consumer(r -> {
try {
val watcher = new FileWatcherService(r.getFile(), file -> createSigningWallet(this.signingCertificateResources));
watcher.start(getClass().getSimpleName());
} catch (final Exception e) {
LOGGER.trace(e.getMessage(), e);
}
}));
createSigningWallet(this.signingCertificateResources);
}
代码示例来源:origin: org.apereo.cas/cas-server-support-person-directory
@ConditionalOnMissingBean(name = "jsonAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> jsonAttributeRepositories() {
val list = new ArrayList<IPersonAttributeDao>();
casProperties.getAuthn().getAttributeRepository().getJson().forEach(Unchecked.consumer(json -> {
val r = json.getLocation();
if (r != null) {
val dao = new JsonBackedComplexStubPersonAttributeDao(r);
dao.setOrder(json.getOrder());
dao.init();
LOGGER.debug("Configured JSON attribute sources from [{}]", r);
list.add(dao);
}
}));
return list;
}
代码示例来源:origin: org.apereo.cas/cas-server-core-configuration-api
@Override
public PropertySource load() {
val properties = new LinkedHashMap<Object, Object>();
val slurper = new ConfigSlurper();
applicationProfiles.forEach(Unchecked.consumer(profile -> {
slurper.setEnvironment(profile);
slurper.registerConditionalBlock("profiles", profile);
val bindings = CollectionUtils.wrap("profile", profile, "logger", LOGGER);
slurper.setBinding(bindings);
val groovyConfig = slurper.parse(getResource().getURL());
val pp = groovyConfig.toProperties();
LOGGER.debug("Found settings [{}] in Groovy file [{}]", pp.keySet(), getResource());
properties.putAll(pp);
}));
return finalizeProperties(decryptProperties(properties));
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-person-directory
@ConditionalOnMissingBean(name = "scriptedAttributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> scriptedAttributeRepositories() {
val list = new ArrayList<IPersonAttributeDao>();
casProperties.getAuthn().getAttributeRepository().getScript()
.forEach(Unchecked.consumer(script -> {
val scriptContents = IOUtils.toString(script.getLocation().getInputStream(), StandardCharsets.UTF_8);
val engineName = script.getEngineName() == null
? ScriptEnginePersonAttributeDao.getScriptEngineName(script.getLocation().getFilename())
: script.getEngineName();
val dao = new ScriptEnginePersonAttributeDao(scriptContents, engineName);
dao.setCaseInsensitiveUsername(script.isCaseInsensitive());
dao.setOrder(script.getOrder());
LOGGER.debug("Configured scripted attribute sources from [{}]", script.getLocation());
list.add(dao);
}));
return list;
}
代码示例来源:origin: org.apereo.cas/cas-server-webapp-config
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable()
.headers().disable()
.logout()
.disable()
.requiresChannel()
.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
.requiresSecure();
val requests = http.authorizeRequests();
configureEndpointAccessToDenyUndefined(http, requests);
configureEndpointAccessForStaticResources(requests);
val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint();
endpoints.forEach(Unchecked.biConsumer((k, v) -> {
val endpoint = EndpointRequest.to(k);
v.getAccess().forEach(Unchecked.consumer(access -> configureEndpointAccess(http, requests, access, v, endpoint)));
}));
}
代码示例来源:origin: org.apereo.cas/cas-server-webapp-config
/**
* Configure endpoint access to deny undefined.
*
* @param http the http
* @param requests the requests
*/
protected void configureEndpointAccessToDenyUndefined(final HttpSecurity http,
final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) {
val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint().keySet();
val configuredEndpoints = endpoints.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
val endpointDefaults = casProperties.getMonitor().getEndpoints().getDefaultEndpointProperties();
endpointDefaults.getAccess().forEach(Unchecked.consumer(access ->
configureEndpointAccess(http, requests, access, endpointDefaults, EndpointRequest.toAnyEndpoint().excluding(configuredEndpoints).excludingLinks())));
}
内容来源于网络,如有侵权,请联系作者删除!