org.nasdanika.common.MapCompoundFunction Maven / Gradle / Ivy
package org.nasdanika.common;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
public class MapCompoundFunction
extends MapCompoundExecutionParticipant>
implements Function> {
public MapCompoundFunction(String name) {
super(name);
}
public MapCompoundFunction(String name, Map> functions) {
super(name);
functions.forEach(this::put);
}
@Override
public Map execute(T arg, ProgressMonitor progressMonitor) {
progressMonitor.setWorkRemaining(size());
Map result = new LinkedHashMap<>();
for (Entry> e: elements.entrySet()) {
Function super T, ? extends R> value = e.getValue();
if (value != null) {
result.put(e.getKey(), value.splitAndExecute(arg, progressMonitor));
}
}
return result;
}
}