org.openlr.encoder.CompositeProcessor Maven / Gradle / Ivy
The newest version!
package org.openlr.encoder;
import org.openlr.map.Line;
import org.openlr.map.Path;
import java.util.List;
import java.util.OptionalDouble;
class CompositeProcessor implements IntermediateProcessor {
private final List processors;
CompositeProcessor(List processors) {
this.processors = processors;
}
@Override
public > OptionalDouble getDistanceToNext(Path path) {
return processors.stream()
.map(processor -> processor.getDistanceToNext(path))
.filter(OptionalDouble::isPresent)
.mapToDouble(OptionalDouble::getAsDouble)
.min();
}
}