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

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

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

Unchecked.consumer介绍

[英]Wrap a CheckedConsumer in a Consumer.

Example: ``

  1. Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  2. if (s.length() > 10)
  3. throw new Exception("Only short strings allowed");
  4. }));

[中]将选中的消费者包装到消费者中。
示例:``

  1. Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  2. if (s.length() > 10)
  3. throw new Exception("Only short strings allowed");
  4. }));

代码示例

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

  1. dataAndExpected.add(new Tuple3<>(13, 12, null));
  2. dataAndExpected.forEach(Unchecked.consumer(data -> {
  3. Map<String, Object> result = handler.substringSearch(file, pattern, data.v1());
  4. assertEquals(data.v3(), result.get("nextByteOffset"));

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

  1. /**
  2. * @see {@link Unchecked#consumer(CheckedConsumer)}
  3. */
  4. static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer) {
  5. return Unchecked.consumer(consumer);
  6. }

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

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

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

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

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

  1. /**
  2. * @see {@link Unchecked#consumer(CheckedConsumer)}
  3. */
  4. static <T> Consumer<T> unchecked(CheckedConsumer<T> consumer) {
  5. return Unchecked.consumer(consumer);
  6. }

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

  1. /**
  2. * Wrap a {@link CheckedConsumer} in a {@link Consumer}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  7. * if (s.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. * }));
  10. * </pre></code>
  11. */
  12. public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
  13. return Unchecked.consumer(consumer, Unchecked.RETHROW_ALL);
  14. }

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

  1. /**
  2. * Wrap a {@link CheckedConsumer} in a {@link Consumer}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  7. * if (s.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. * }));
  10. * </pre></code>
  11. */
  12. public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
  13. return consumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
  14. }

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

  1. /**
  2. * Wrap a {@link CheckedConsumer} in a {@link Consumer}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  7. * if (s.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. * }));
  10. * </pre></code>
  11. */
  12. public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
  13. return consumer(consumer, THROWABLE_TO_RUNTIME_EXCEPTION);
  14. }

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

  1. /**
  2. * Wrap a {@link CheckedConsumer} in a {@link Consumer}.
  3. * <p>
  4. * Example:
  5. * <code><pre>
  6. * Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
  7. * if (s.length() > 10)
  8. * throw new Exception("Only short strings allowed");
  9. * }));
  10. * </pre></code>
  11. */
  12. public static <T> Consumer<T> consumer(CheckedConsumer<T> consumer) {
  13. return Unchecked.consumer(consumer, Unchecked.RETHROW_ALL);
  14. }

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

  1. private void copyRecursively(final String path) {
  2. resourcesFrom(path, Integer.MAX_VALUE)
  3. .sorted((s1, s2) -> Integer.compare(s2.length(), s1.length())) // Longest first
  4. .forEach(Unchecked.consumer(p -> {
  5. try (InputStream is = NewProjLayoutSelectController.class.getResourceAsStream(path + '/' + p)) {
  6. final File destination = new File(folderPath + '/' + p);
  7. if (!destination.exists()) {
  8. FileUtils.copyInputStreamToFile(is, destination);
  9. }
  10. }
  11. }));
  12. }

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

  1. ServiceConfigurationInformation(List<ServiceConfiguration> serviceConfigurations) {
  2. this.serviceConfigurations = serviceConfigurations;
  3. this.flattenConfiguration = new HashMap<>();
  4. serviceConfigurations.forEach(Unchecked.consumer(sc -> flattenConfiguration.putAll(sc.getConfigurationMap())));
  5. }

代码示例来源:origin: org.apereo.cas/cas-server-support-x509-core

  1. @Override
  2. public void serialize(final X509CertificateCredential value,
  3. final JsonGenerator generator, final SerializerProvider serializerProvider)
  4. throws IOException {
  5. generator.writeArrayFieldStart("certificates");
  6. Arrays.stream(value.getCertificates()).forEach(Unchecked.consumer(c -> generator.writeBinary(c.getEncoded())));
  7. generator.writeEndArray();
  8. }

代码示例来源:origin: org.apereo.cas/cas-mgmt-core-authz

  1. private void watchResource(final Resource usersFile) {
  2. try (
  3. val watcher = new FileWatcherService(usersFile.getFile(),
  4. Unchecked.consumer(file -> loadResource(usersFile)))) {
  5. watcher.start(getClass().getSimpleName());
  6. } catch (final Exception e) {
  7. LOGGER.debug(e.getMessage(), e);
  8. }
  9. }

代码示例来源:origin: org.apereo.cas/cas-mgmt-core-authz

  1. private void watchResource(final Resource usersFile) {
  2. try (
  3. val watcher = new FileWatcherService(usersFile.getFile(),
  4. Unchecked.consumer(file -> {
  5. val newProps = new Properties();
  6. val input = Files.newInputStream(file.toPath());
  7. newProps.load(input);
  8. input.close();
  9. this.generator = new SpringSecurityPropertiesAuthorizationGenerator(newProps);
  10. }))) {
  11. watcher.start(getClass().getSimpleName());
  12. } catch (final Exception e) {
  13. LOGGER.debug(e.getMessage(), e);
  14. }
  15. }

代码示例来源:origin: org.apereo.cas/cas-server-support-wsfederation

  1. public void initialize() {
  2. this.signingCertificateResources.forEach(Unchecked.consumer(r -> {
  3. try {
  4. val watcher = new FileWatcherService(r.getFile(), file -> createSigningWallet(this.signingCertificateResources));
  5. watcher.start(getClass().getSimpleName());
  6. } catch (final Exception e) {
  7. LOGGER.trace(e.getMessage(), e);
  8. }
  9. }));
  10. createSigningWallet(this.signingCertificateResources);
  11. }

代码示例来源:origin: org.apereo.cas/cas-server-support-person-directory

  1. @ConditionalOnMissingBean(name = "jsonAttributeRepositories")
  2. @Bean
  3. @RefreshScope
  4. public List<IPersonAttributeDao> jsonAttributeRepositories() {
  5. val list = new ArrayList<IPersonAttributeDao>();
  6. casProperties.getAuthn().getAttributeRepository().getJson().forEach(Unchecked.consumer(json -> {
  7. val r = json.getLocation();
  8. if (r != null) {
  9. val dao = new JsonBackedComplexStubPersonAttributeDao(r);
  10. dao.setOrder(json.getOrder());
  11. dao.init();
  12. LOGGER.debug("Configured JSON attribute sources from [{}]", r);
  13. list.add(dao);
  14. }
  15. }));
  16. return list;
  17. }

代码示例来源:origin: org.apereo.cas/cas-server-core-configuration-api

  1. @Override
  2. public PropertySource load() {
  3. val properties = new LinkedHashMap<Object, Object>();
  4. val slurper = new ConfigSlurper();
  5. applicationProfiles.forEach(Unchecked.consumer(profile -> {
  6. slurper.setEnvironment(profile);
  7. slurper.registerConditionalBlock("profiles", profile);
  8. val bindings = CollectionUtils.wrap("profile", profile, "logger", LOGGER);
  9. slurper.setBinding(bindings);
  10. val groovyConfig = slurper.parse(getResource().getURL());
  11. val pp = groovyConfig.toProperties();
  12. LOGGER.debug("Found settings [{}] in Groovy file [{}]", pp.keySet(), getResource());
  13. properties.putAll(pp);
  14. }));
  15. return finalizeProperties(decryptProperties(properties));
  16. }
  17. }

代码示例来源:origin: org.apereo.cas/cas-server-support-person-directory

  1. @ConditionalOnMissingBean(name = "scriptedAttributeRepositories")
  2. @Bean
  3. @RefreshScope
  4. public List<IPersonAttributeDao> scriptedAttributeRepositories() {
  5. val list = new ArrayList<IPersonAttributeDao>();
  6. casProperties.getAuthn().getAttributeRepository().getScript()
  7. .forEach(Unchecked.consumer(script -> {
  8. val scriptContents = IOUtils.toString(script.getLocation().getInputStream(), StandardCharsets.UTF_8);
  9. val engineName = script.getEngineName() == null
  10. ? ScriptEnginePersonAttributeDao.getScriptEngineName(script.getLocation().getFilename())
  11. : script.getEngineName();
  12. val dao = new ScriptEnginePersonAttributeDao(scriptContents, engineName);
  13. dao.setCaseInsensitiveUsername(script.isCaseInsensitive());
  14. dao.setOrder(script.getOrder());
  15. LOGGER.debug("Configured scripted attribute sources from [{}]", script.getLocation());
  16. list.add(dao);
  17. }));
  18. return list;
  19. }

代码示例来源:origin: org.apereo.cas/cas-server-webapp-config

  1. @Override
  2. protected void configure(final HttpSecurity http) throws Exception {
  3. http.csrf().disable()
  4. .headers().disable()
  5. .logout()
  6. .disable()
  7. .requiresChannel()
  8. .requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
  9. .requiresSecure();
  10. val requests = http.authorizeRequests();
  11. configureEndpointAccessToDenyUndefined(http, requests);
  12. configureEndpointAccessForStaticResources(requests);
  13. val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint();
  14. endpoints.forEach(Unchecked.biConsumer((k, v) -> {
  15. val endpoint = EndpointRequest.to(k);
  16. v.getAccess().forEach(Unchecked.consumer(access -> configureEndpointAccess(http, requests, access, v, endpoint)));
  17. }));
  18. }

代码示例来源:origin: org.apereo.cas/cas-server-webapp-config

  1. /**
  2. * Configure endpoint access to deny undefined.
  3. *
  4. * @param http the http
  5. * @param requests the requests
  6. */
  7. protected void configureEndpointAccessToDenyUndefined(final HttpSecurity http,
  8. final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) {
  9. val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint().keySet();
  10. val configuredEndpoints = endpoints.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
  11. val endpointDefaults = casProperties.getMonitor().getEndpoints().getDefaultEndpointProperties();
  12. endpointDefaults.getAccess().forEach(Unchecked.consumer(access ->
  13. configureEndpointAccess(http, requests, access, endpointDefaults, EndpointRequest.toAnyEndpoint().excluding(configuredEndpoints).excludingLinks())));
  14. }

相关文章