1 17 18 package com.whirlycott.cache.policy; 19 20 import java.util.Map.Entry; 21 22 import org.apache.commons.collections.Predicate; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 import com.whirlycott.cache.Item; 27 28 34 public class ExpirationTimePredicate implements Predicate { 35 36 39 private static final Log log = LogFactory.getLog(ExpirationTimePredicate.class); 40 41 private final long currentTime; 42 43 49 public ExpirationTimePredicate(final long currentTime) { 50 this.currentTime = currentTime; 51 } 52 53 57 public boolean evaluate(final Object obj) { 58 boolean retval = false; 59 60 if (obj instanceof Entry) { 61 if (((Entry) obj).getValue() instanceof Item) { 62 final Item item = (Item) ((Entry) obj).getValue(); 63 if (item.getExpiresAfter() > 0) { 64 69 retval = ((item.getExpiresAfter() + item.getAdded()) < currentTime); 70 } 71 } 72 } 73 74 return retval; 75 } 76 } | Popular Tags |