use of lombok.core.configuration.ConfigurationSource.Result in project lombok by rzwitserloot.
the class FileSystemSourceCache method sourcesForDirectory.
private Iterable<ConfigurationSource> sourcesForDirectory(final File directory, final ConfigurationProblemReporter reporter) {
return new Iterable<ConfigurationSource>() {
@Override
public Iterator<ConfigurationSource> iterator() {
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;
}
@Override
public ConfigurationSource next() {
if (!hasNext())
throw new NoSuchElementException();
ConfigurationSource result = next;
next = null;
return result;
}
private ConfigurationSource findNext() {
while (currentDirectory != null && next == null) {
next = getSourceForDirectory(currentDirectory, reporter);
currentDirectory = currentDirectory.getParentFile();
}
if (next != null) {
Result stop = next.resolve(ConfigurationKeys.STOP_BUBBLING);
stopBubbling = (stop != null && Boolean.TRUE.equals(stop.getValue()));
}
return next;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
use of lombok.core.configuration.ConfigurationSource.Result in project lombok by rzwitserloot.
the class BubblingConfigurationResolver method resolve.
@SuppressWarnings("unchecked")
@Override
public <T> T resolve(ConfigurationKey<T> key) {
boolean isList = key.getType().isList();
List<List<ListModification>> listModificationsList = null;
for (ConfigurationSource source : sources) {
Result result = source.resolve(key);
if (result == null)
continue;
if (isList) {
if (listModificationsList == null)
listModificationsList = new ArrayList<List<ListModification>>();
listModificationsList.add((List<ListModification>) result.getValue());
}
if (result.isAuthoritative()) {
if (isList)
break;
return (T) result.getValue();
}
}
if (!isList)
return null;
if (listModificationsList == null)
return (T) Collections.emptyList();
List<Object> listValues = new ArrayList<Object>();
Collections.reverse(listModificationsList);
for (List<ListModification> listModifications : listModificationsList) {
if (listModifications != null)
for (ListModification modification : listModifications) {
listValues.remove(modification.getValue());
if (modification.isAdded())
listValues.add(modification.getValue());
}
}
return (T) listValues;
}
Aggregations