// Path: src/main/java/com/codefork/refine/resources/Result.java
// public class Result {
//     
//     private String id;
//     private String name;
// 
//     /**
//      * It's weird that this is a list but that's what OpenRefine expects.
//      * A VIAF result only ever has one type, but maybe other reconciliation
//      * services return multiple types for a name?
//      */
//     private List<VIAFNameType> type;
//     private double score;
//     private boolean match;
// 
//     public Result(String id, String name, NameType nameType, double score, boolean match) {
//         this.id = id;
//         this.name = name;
//         this.type = new ArrayList<VIAFNameType>();
//         this.type.add(nameType.asVIAFNameType());
//         this.score = score;
//         this.match = match;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public List<VIAFNameType> getType() {
//         return type;
//     }
// 
//     public void setType(List<VIAFNameType> resultType) {
//         this.type = resultType;
//     }
// 
//     public double getScore() {
//         return score;
//     }
// 
//     public void setScore(double score) {
//         this.score = score;
//     }
// 
//     public boolean isMatch() {
//         return match;
//     }
// 
//     public void setMatch(boolean match) {
//         this.match = match;
//     }
// 
// }


import com.codefork.refine.resources.Result;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;
package com.codefork.refine;



/**
 * Takes care of the Cache, including the thread that expires it periodically.
 * We need this because the Cache object gets replaced when it expires,
 * so there needs to be this intermediate object for synchronizing access
 * to the Cache object.
 */
public class CacheManager {

    Log log = LogFactory.getLog(CacheManager.class);

    private Cache<String, List<Result>> cache = new Cache<String, List<Result>>();
    private Object cacheLock = new Object();
    private CacheExpire cacheExpire;
    private Thread thread;

    public void startExpireThread() {
        if(!isExpireThreadRunning()) {
            cacheExpire = new CacheExpire(this);

            thread = new Thread(cacheExpire);
            thread.setDaemon(true);
            thread.start();
        }
    }

    public void stopExpireThread() {
        if(isExpireThreadRunning()) {
            thread.interrupt();
            thread = null;
        }
    }

    public boolean isExpireThreadRunning() {
        return thread != null;
    }

    public void expireCache() {
// Path: src/main/java/com/codefork/refine/resources/Result.java
// public class Result {
//     
//     private String id;
//     private String name;
// 
//     /**
//      * It's weird that this is a list but that's what OpenRefine expects.
//      * A VIAF result only ever has one type, but maybe other reconciliation
//      * services return multiple types for a name?
//      */
//     private List<VIAFNameType> type;
//     private double score;
//     private boolean match;
// 
//     public Result(String id, String name, NameType nameType, double score, boolean match) {
//         this.id = id;
//         this.name = name;
//         this.type = new ArrayList<VIAFNameType>();
//         this.type.add(nameType.asVIAFNameType());
//         this.score = score;
//         this.match = match;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public List<VIAFNameType> getType() {
//         return type;
//     }
// 
//     public void setType(List<VIAFNameType> resultType) {
//         this.type = resultType;
//     }
// 
//     public double getScore() {
//         return score;
//     }
// 
//     public void setScore(double score) {
//         this.score = score;
//     }
// 
//     public boolean isMatch() {
//         return match;
//     }
// 
//     public void setMatch(boolean match) {
//         this.match = match;
//     }
// 
// }


// Path: src/main/java/com/codefork/refine/CacheManager.java
import com.codefork.refine.resources.Result;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;

package com.codefork.refine;



/**
 * Takes care of the Cache, including the thread that expires it periodically.
 * We need this because the Cache object gets replaced when it expires,
 * so there needs to be this intermediate object for synchronizing access
 * to the Cache object.
 */
public class CacheManager {

    Log log = LogFactory.getLog(CacheManager.class);

    private Cache<String, List<Result>> cache = new Cache<String, List<Result>>();
    private Object cacheLock = new Object();
    private CacheExpire cacheExpire;
    private Thread thread;

    public void startExpireThread() {
        if(!isExpireThreadRunning()) {
            cacheExpire = new CacheExpire(this);

            thread = new Thread(cacheExpire);
            thread.setDaemon(true);
            thread.start();
        }
    }

    public void stopExpireThread() {
        if(isExpireThreadRunning()) {
            thread.interrupt();
            thread = null;
        }
    }

    public boolean isExpireThreadRunning() {
        return thread != null;
    }

    public void expireCache() {
        if (cache.getCount() > 0) {