Instantly share code, notes, and snippets.

View CompletableFutureExample.java
/*
Adobe HTTP Client ex: https://stackoverflow.com/questions/37434906/how-do-i-get-a-completablefuturet-from-an-async-http-client-request#37437643
*/
CompletableFuture<Response> f = asyncHttpClient
.prepareGet("http://api.football-data.org/v1/soccerseasons/398")
.execute()
.toCompletableFuture();
View AsyncThreads.java
/*
src: https://github.com/eugenp/tutorials/blob/2e2f3bc4a95f83b91188b5ea7ee75e7913d3fe03/libraries/src/main/java/com/baeldung/loom/AsyncThreads.java
Adobe HTTP Client ex: https://stackoverflow.com/questions/37434906/how-do-i-get-a-completablefuturet-from-an-async-http-client-request#37437643
CompletableFuture<Response> f = asyncHttpClient
.prepareGet("http://api.football-data.org/v1/soccerseasons/398")
.execute()
.toCompletableFuture();
*/
View StreamReduce.java
/*
src: https://github.com/eugenp/tutorials/blob/3a3e31510c1de1cc3209c8768d16cab86fb17a81/java-streams/src/main/java/com/baeldung/stream/StreamReduce.java
*/
import java.util.Arrays;
import java.util.Collection;
import java.util.IntSummaryStatistics;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.stream.IntStream;
View DynamicSelectDataSourceTest.java
/*
src: https://github.com/joerghoh/acs-aem-commons/blob/57cbf3048de3ab02a00e8a54f496bc1bbcd8c7eb/bundle/src/test/java/com/adobe/acs/commons/reports/internal/datasources/DynamicSelectDataSourceTest.java
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2017 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
View FormsPostFilterImpl.java
/*
src: https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/3c8159b5ba4e1765cef631f9f23a46f3e3c9bde8/bundle/src/main/java/com/adobe/acs/commons/forms/impl/FormsPostFilterImpl.java
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2013 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
View PostRedirectGetFormHelperImplTest.java
/*
src: https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/b6c622da8391c036367e2a73ab558e6bca275a37/bundle/src/test/java/com/adobe/acs/commons/forms/helpers/impl/PostRedirectGetFormHelperImplTest.java
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2017 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
View EnumSingletonElement3
import java.util.HashMap;
import java.util.Map;
/**
* A Map has been added to cache labels for faster lookup.
* from https://github.com/pandachris/tutorials/blob/53e6490c61cf0b6a41ab31e394b1472188987bc9/core-java-8/src/main/java/com/baeldung/enums/values/Element3.java
*/
public enum EnumSingletonElement3 {
H("Hydrogen"),
HE("Helium"),
View Java8PredicateChainUnitTest.java
// src: https://github.com/eugenp/tutorials/blob/2f7c16e00df9eb29b7171245bfce333458735910/core-java-8/src/test/java/com/baeldung/java8/Java8PredicateChainUnitTest.java
package com.baeldung.java8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
View CustomFunctionTestsJava.java
/* src: java8LambdasVsGroovyClosures/src/main/java/ch/codebulb/java8lambdasvsgroovy/CustomFunctionTestsJava.java
* https://github.com/codebulb/java8LambdasVsGroovyClosures/blob/master/src/main/java/ch/codebulb/java8lambdasvsgroovy/CustomFunctionTestsJava.java
*
*/
import java.util.function.Function;
public class CustomFunctionTestsJava {
protected static int INPUT_VALUE;
protected static String INPUT_STRING;
View SyntaxTestsJava.java
/* src: java8LambdasVsGroovyClosures/src/main/java/ch/codebulb/java8lambdasvsgroovy/SyntaxTestsJava.java
* https://github.com/codebulb/java8LambdasVsGroovyClosures/blob/master/src/main/java/ch/codebulb/java8lambdasvsgroovy/SyntaxTestsJava.java
*/
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class SyntaxTestsJava {
protected static List<String> INPUT_LIST;