angry1980.audio.dao.PeakDAOInMemoryImpl Maven / Gradle / Ivy
package angry1980.audio.dao;
import angry1980.audio.model.Peak;
import java.util.*;
public class PeakDAOInMemoryImpl implements PeakDAO {
private Map> index;
public PeakDAOInMemoryImpl() {
this.index = new HashMap<>();
}
@Override
public List findByHash(long hash) {
return index.getOrDefault(hash, Collections.emptyList());
}
@Override
public Optional create(Peak point) {
index.computeIfAbsent(point.getHash(), v -> new ArrayList<>()).add(point);
return Optional.of(point);
}
}