All Downloads are FREE. Search and download functionalities are using the official Maven repository.

angry1980.audio.dao.PeakDAOInMemoryImpl Maven / Gradle / Ivy

There is a newer version: 0.0.10
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy