Polishing

This commit is contained in:
Juergen Hoeller
2018-07-24 15:17:33 +02:00
parent 484addb4f8
commit 2ae2249842
4 changed files with 37 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
* invocation context.
*
* @author Stephane Nicoll
* @author Juergen Hoeller
* @since 4.1
*/
public abstract class AbstractCacheResolver implements CacheResolver, InitializingBean {
@@ -38,9 +39,17 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
private CacheManager cacheManager;
/**
* Construct a new {@code AbstractCacheResolver}.
* @see #setCacheManager
*/
protected AbstractCacheResolver() {
}
/**
* Construct a new {@code AbstractCacheResolver} for the given {@link CacheManager}.
* @param cacheManager the CacheManager to use
*/
protected AbstractCacheResolver(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
@@ -72,18 +81,16 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
if (cacheNames == null) {
return Collections.emptyList();
}
else {
Collection<Cache> result = new ArrayList<Cache>();
for (String cacheName : cacheNames) {
Cache cache = getCacheManager().getCache(cacheName);
if (cache == null) {
throw new IllegalArgumentException("Cannot find cache named '" +
cacheName + "' for " + context.getOperation());
}
result.add(cache);
Collection<Cache> result = new ArrayList<Cache>(cacheNames.size());
for (String cacheName : cacheNames) {
Cache cache = getCacheManager().getCache(cacheName);
if (cache == null) {
throw new IllegalArgumentException("Cannot find cache named '" +
cacheName + "' for " + context.getOperation());
}
return result;
result.add(cache);
}
return result;
}
/**