private <T> Cache<T> buildCache( Cache<T> cache, Loader<T> loader, TypedCacheBuilder<T> typedCacheBuilder ) { if (cache != null) { return cache; } if (loader == null) { throw new IllegalStateException("'loader' must be set"); } if (cacheBuilder != null) { final Cache<T> c = cacheBuilder.build(loader); if (c == null) { throw new IllegalStateException("'cacheBuilder' must return non-null values"); } return c; } if (typedCacheBuilder != null) { return typedCacheBuilder.build(loader); } throw new IllegalStateException("No cache implementation is configured"); }