HashMap<Integer,Integer> hm = new HashMap<Integer, Integer>(); /* * Logic to put the Key,Value pair in your HashMap hm */ // Print the key value pair in one line. hm.forEach((k,v) -> System.out.println("key: "+k+" value:"+v));
hm.forEach((k,v) -> System.out.println("key: "+k+" value:"+v));
@Override public String toString() { final ToStringBuilder sb = new ToStringBuilder(this); super.forEach((key, value) -> sb.append(key, String.format("<%s>%s", value.getClass().getCanonicalName(), value))); return sb.build(); } }
@Override public CompletableFuture<Void> closeAsync() { if (closed) { return closeFuture; } closed = true; HashMap<RedisURI, ConnectionFuture<StatefulRedisPubSubConnection<String, String>>> connections = new HashMap<>( pubSubConnections); List<CompletableFuture<Void>> futures = new ArrayList<>(); connections.forEach((k, f) -> { futures.add(f.exceptionally(t -> null).thenCompose(c -> { if (c == null) { return CompletableFuture.completedFuture(null); } c.removeListener(adapter); return c.closeAsync(); }).toCompletableFuture()); pubSubConnections.remove(k); }); Futures.allOf(futures).whenComplete((aVoid, throwable) -> { if (throwable != null) { closeFuture.completeExceptionally(throwable); } else { closeFuture.complete(null); } }); return closeFuture; }
@Test public void testRequestHeadersWithCharSequence() { HashMap<CharSequence, String> headers = new HashMap<>(); headers.put(HttpHeaders.TEXT_HTML, "text/html"); headers.put(HttpHeaders.USER_AGENT, "User-Agent"); headers.put(HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED, "application/x-www-form-urlencoded"); server.requestHandler(req -> { assertTrue(headers.size() < req.headers().size()); headers.forEach((k, v) -> assertEquals(v, req.headers().get(k))); headers.forEach((k, v) -> assertEquals(v, req.getHeader(k))); req.response().end(); }); server.listen(onSuccess(server -> { HttpClientRequest req = client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> testComplete()); headers.forEach((k, v) -> req.headers().add(k, v)); req.end(); })); await(); }
@Test public void testResponseHeadersWithCharSequence() { HashMap<CharSequence, String> headers = new HashMap<>(); headers.put(HttpHeaders.TEXT_HTML, "text/html"); headers.put(HttpHeaders.USER_AGENT, "User-Agent"); headers.put(HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED, "application/x-www-form-urlencoded"); server.requestHandler(req -> { headers.forEach((k, v) -> req.response().headers().add(k, v)); req.response().end(); }); server.listen(onSuccess(server -> { client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, onSuccess(resp -> { assertTrue(headers.size() < resp.headers().size()); headers.forEach((k,v) -> assertEquals(v, resp.headers().get(k))); headers.forEach((k,v) -> assertEquals(v, resp.getHeader(k))); testComplete(); })).end(); })); await(); }
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
/** * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
/** * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
/** * @deprecated Deprecated as of 2.7.0. {@link Flash} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
/** * @deprecated Deprecated as of 2.7.0. {@link Session} will not be a subclass of {@link HashMap} in future Play releases. */ @Deprecated @Override public void forEach(BiConsumer<? super String, ? super String> action) { super.forEach(action); }
HashMap<Integer,Integer> hm = new HashMap<Integer, Integer>(); /* * Logic to put the Key,Value pair in your HashMap hm */ // Print the key value pair in one line. hm.forEach((k,v) -> System.out.println("key: "+k+" value:"+v)); // Just copy and paste above line to your code.
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = context.getDeploymentUnit(); String contextID = deploymentUnit.getName(); if (deploymentUnit.getParent() != null) { contextID = deploymentUnit.getParent().getName() + "!" + contextID; } EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description; final boolean securityRequired = isExplicitSecurityDomainConfigured(); ejbComponentDescription.setSecurityRequired(securityRequired); if (isSecurityDomainKnown()) { final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(contextID, ejbComponentDescription.isEnableJacc(), false); elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addPostConstructInterceptor(elytronInterceptorFactory, priority)); } else { configuration.addPostConstructInterceptor(new SecurityContextInterceptorFactory(securityRequired, false, contextID), InterceptorOrder.View.SECURITY_CONTEXT); } } });
if (ejbComponentDescription.isSecurityDomainKnown()) { final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(policyContextID, ejbComponentDescription.isEnableJacc(), true); elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addTimeoutViewInterceptor(elytronInterceptorFactory, priority)); } else if (deploymentUnit.hasAttachment(SecurityAttachments.SECURITY_ENABLED)) { configuration.addTimeoutViewInterceptor(new SecurityContextInterceptorFactory(securityRequired, policyContextID), InterceptorOrder.View.SECURITY_CONTEXT);
elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> viewConfiguration.addViewInterceptor(elytronInterceptorFactory, priority)); } else { viewConfiguration.addViewInterceptor(new SecurityContextInterceptorFactory(securityRequired, true, contextID), InterceptorOrder.View.SECURITY_CONTEXT);
hm.forEach((k,v) -> System.out.println("key: "+k+" value:"+v));
@Test public void testRequestHeadersWithCharSequence() { HashMap<CharSequence, String> headers = new HashMap<>(); headers.put(HttpHeaders.TEXT_HTML, "text/html"); headers.put(HttpHeaders.USER_AGENT, "User-Agent"); headers.put(HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED, "application/x-www-form-urlencoded"); server.requestHandler(req -> { assertTrue(headers.size() < req.headers().size()); headers.forEach((k, v) -> assertEquals(v, req.headers().get(k))); headers.forEach((k, v) -> assertEquals(v, req.getHeader(k))); req.response().end(); }); server.listen(onSuccess(server -> { HttpClientRequest req = client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> testComplete()); headers.forEach((k, v) -> req.headers().add(k, v)); req.end(); })); await(); }
@Test public void testResponseHeadersWithCharSequence() { HashMap<CharSequence, String> headers = new HashMap<>(); headers.put(HttpHeaders.TEXT_HTML, "text/html"); headers.put(HttpHeaders.USER_AGENT, "User-Agent"); headers.put(HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED, "application/x-www-form-urlencoded"); server.requestHandler(req -> { headers.forEach((k, v) -> req.response().headers().add(k, v)); req.response().end(); }); server.listen(onSuccess(server -> { client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> { assertTrue(headers.size() < resp.headers().size()); headers.forEach((k,v) -> assertEquals(v, resp.headers().get(k))); headers.forEach((k,v) -> assertEquals(v, resp.getHeader(k))); testComplete(); }).end(); })); await(); }