[ 
https://issues.apache.org/jira/browse/OPENNLP-887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joern Kottmann closed OPENNLP-887.
----------------------------------
    Resolution: Fixed

> Replace the Cache class with a LinkedHashMap
> --------------------------------------------
>
>                 Key: OPENNLP-887
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-887
>             Project: OpenNLP
>          Issue Type: Improvement
>            Reporter: Joern Kottmann
>            Assignee: Suneel Marthi
>            Priority: Minor
>             Fix For: 1.7.0
>
>
> The existing cache implementation could be replaced with 
> java.util.LinkedHashMap. This change would replace our custom implementation 
> with an implementation which will be maintained for us.
> To have the same behaviour as our implementation LinkedHashMap must be 
> subclasses. The LinkedHashMap.removeEldestEntry must be overwritten and 
> return true if size limit is reached.
> This could be something like this:
> import java.util.LinkedHashMap;
> import java.util.Iterator;
> import java.util.Map;
> public class Cache<K, V> extends LinkedHashMap<K,V> {
>     private final int capacity;
>     public Cache(int capacity) {
>         this.capacity = capacity;
>     }
>     @Override
>     protected boolean removeEldestEntry(Map.Entry<K,V> eldest) {
>         return this.size() > this.capacity;
>     }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to