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

com.netgrif.application.engine.elastic.service.MaxSizeHashMap Maven / Gradle / Ivy

Go to download

System provides workflow management functions including user, role and data management.

There is a newer version: 6.3.3
Show newest version
package com.netgrif.application.engine.elastic.service;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MaxSizeHashMap extends LinkedHashMap {

    private final long maxSize;

    MaxSizeHashMap(long maxSize) {
        super(16, 0.75f, true);
        this.maxSize = maxSize;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry eldest) {
        return size() > maxSize;
    }

    @Override
    public ExecutorService get(Object o) {
        ExecutorService executor = super.get(o);
        if (executor == null) {
            executor = Executors.newSingleThreadExecutor();
            put((String) o, executor);
        }
        return executor;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy