Skip to content

Instantly share code, notes, and snippets.

View andresteingress's full-sized avatar
🎯
Focusing

Andre Steingress andresteingress

🎯
Focusing
View GitHub Profile
@andresteingress
andresteingress / gist:9685650
Last active August 29, 2015 13:57
TestHelper's shouldFail in JDK 8
import java.util.Arrays;
import java.util.List;
public class TestHelper {
public static Throwable shouldFail(Runnable code) {
try {
code.run();
} catch (Throwable ex) {
return ex;
@andresteingress
andresteingress / gist:9697217
Last active August 29, 2015 13:57
Memoizer in JDK 8
public class Memoizer {
public static class MemoizeFunction<T, R> implements Function<T, R> {
private final Map<List, R> cache = new HashMap<>();
private final Function<T, R> function;
public MemoizeFunction(Function<T, R> function) {
Objects.requireNonNull(function);
this.function = function;
@andresteingress
andresteingress / gist:11226958
Created April 23, 2014 18:22
ConditionalOnExpression - A conditional EhCache manager configuration
@Configuration
@EnableCaching
@ConditionalOnExpression("${spring.cacheable.cache}")
public class EhCacheConfiguration {
@Autowired
private net.sf.ehcache.CacheManager cacheManager;
@Bean(name = "cacheManager")
public CacheManager ehCacheCacheManager()