io.stargate.web.docsapi.service.json.DeadLeafCollectorImpl Maven / Gradle / Ivy
The newest version!
package io.stargate.web.docsapi.service.json;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class DeadLeafCollectorImpl implements DeadLeafCollector {
private final Map> deadPaths;
public DeadLeafCollectorImpl() {
deadPaths = new HashMap<>();
}
@Override
public void addLeaf(String path, DeadLeaf leaf) {
Set leavesAtPath = deadPaths.getOrDefault(path, new HashSet<>());
leavesAtPath.add(leaf);
deadPaths.put(path, leavesAtPath);
}
@Override
public void addArray(String path) {
Set leavesAtPath = deadPaths.getOrDefault(path, new HashSet<>());
leavesAtPath.add(DeadLeaf.ARRAYLEAF);
deadPaths.put(path, leavesAtPath);
}
@Override
public void addAll(String path) {
Set leavesAtPath = new HashSet<>();
leavesAtPath.add(DeadLeaf.STARLEAF);
deadPaths.put(path, leavesAtPath);
}
public Map> getLeaves() {
return deadPaths;
}
@Override
public boolean isEmpty() {
return deadPaths.isEmpty();
}
}