[configuration] Move the responsibility to stop bubbling to the iterator

This commit is contained in:
Roel Spilker committed 2014-01-19 02:25:23 +01:00
1 parent 3415221322
commit 2f0d7614d4
2 files changed
+9 -4

No files matched your search

@@ -30,8 +30,6 @@ import lombok.core.configuration.ConfigurationSource.Result;
public class BubblingConfigurationResolver implements ConfigurationResolver {
private static final ConfigurationKey<Boolean> STOP_BUBBLING = new ConfigurationKey<Boolean>("stop-bubbling") {};
private final Iterable<ConfigurationSource> sources;
public BubblingConfigurationResolver(Iterable<ConfigurationSource> sources) {
@@ -59,8 +57,6 @@ public class BubblingConfigurationResolver implements ConfigurationResolver {
}
return (T) result.getValue();
}
Result stop = source.resolve(STOP_BUBBLING);
if (stop != null && Boolean.TRUE.equals(stop.getValue())) break;
}
if (!isList) {
return null;
@@ -32,6 +32,9 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import lombok.ConfigurationKeys;
import lombok.core.configuration.ConfigurationSource.Result;
public class FileSystemSourceCache {
private static String LOMBOK_CONFIG_FILENAME = "lombok.config";
@@ -49,10 +52,12 @@ public class FileSystemSourceCache {
return new Iterator<ConfigurationSource>() {
File currentDirectory = directory;
ConfigurationSource next;
boolean stopBubbling = false;
@Override
public boolean hasNext() {
if (next != null) return true;
if (stopBubbling) return false;
next = findNext();
return next != null;
}
@@ -70,6 +75,10 @@ public class FileSystemSourceCache {
next = getSourceForDirectory(currentDirectory, reporterFactory);
currentDirectory = currentDirectory.getParentFile();
}
if (next != null) {
Result stop = next.resolve(ConfigurationKeys.STOP_BUBBLING);
stopBubbling = (stop != null && Boolean.TRUE.equals(stop.getValue()));
}
return next;
}