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

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

There is a newer version: 0.0.10
Show newest version
package angry1980.audio.dao;

import angry1980.audio.model.TrackHash;

import java.util.*;

public class TrackHashDAOInMemoryImpl implements TrackHashDAO {

    private Map> index;

    public TrackHashDAOInMemoryImpl(){
        this.index = new HashMap<>();
    }

    @Override
    public Optional create(TrackHash hash) {
        index.computeIfAbsent(hash.getHash(), l -> new ArrayList()).add(hash);
        return Optional.of(hash);
    }

    @Override
    public List findByHash(int hash) {
        return index.getOrDefault(hash, Collections.emptyList());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy