package cn.trinea.android.common.service.impl;
import cn.trinea.android.common.entity.CacheObject;
import cn.trinea.android.common.service.CacheFullRemoveType;
/**
* Remove type when cache is full.<br/>
* when cache is full, compare used count of object in cache, if is bigger remove it first.<br/>
*
* @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2011-12-26
*/
public class RemoveTypeUsedCountBig<T> implements CacheFullRemoveType<T> {
private static final long serialVersionUID = 1L;
@Override
public int compare(CacheObject<T> obj1, CacheObject<T> obj2) {
return (obj2.getUsedCount() > obj1.getUsedCount()) ? 1
: ((obj2.getUsedCount() == obj1.getUsedCount()) ? 0 : -1);
}
}