use of lombok.core.configuration.ConfigurationSource.ListModification 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