io.kroxylicious.proxy.config.model.VisitableMap Maven / Gradle / Ivy
package io.kroxylicious.proxy.config.model;
import java.util.stream.Collectors;
import java.lang.Iterable;
import java.util.function.Consumer;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.lang.Object;
import java.util.List;
import java.lang.String;
import java.util.Spliterator;
public class VisitableMap extends HashMap>> implements Iterable>{
public List> get(Object key) {
if (!containsKey(key)) {
put(String.valueOf(key), new ArrayList());
}
return super.get(key);
}
public List> aggregate() {
return values().stream().flatMap(l -> l.stream()).collect(Collectors.toList());
}
public Iterator> iterator() {
return aggregate().iterator();
}
public void forEach(Consumer super Visitable>> action) {
aggregate().forEach(action);
}
public Spliterator spliterator() {
return aggregate().spliterator();
}
}