SPR-17074 Replace pointless wrapping with Arrays.asList with iteration over array

This commit is contained in:
stsypanov
2018-08-01 23:04:05 +03:00
committed by Juergen Hoeller
parent 29ce6685ca
commit b5c691bdac
4 changed files with 10 additions and 7 deletions

View File

@@ -229,13 +229,14 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
@Override
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
Assert.notNull(mergedConfig, "mergedConfig must not be null");
List<SmartContextLoader> candidates = Arrays.asList(getXmlLoader(), getAnnotationConfigLoader());
Assert.state(!(mergedConfig.hasLocations() && mergedConfig.hasClasses()), () -> String.format(
"Neither %s nor %s supports loading an ApplicationContext from %s: " +
"declare either 'locations' or 'classes' but not both.", name(getXmlLoader()),
name(getAnnotationConfigLoader()), mergedConfig));
SmartContextLoader[] candidates = {getXmlLoader(), getAnnotationConfigLoader()};
for (SmartContextLoader loader : candidates) {
// Determine if each loader can load a context from the mergedConfig. If it
// can, let it; otherwise, keep iterating.