1 /*** 2 * 3 */ 4 package de.cohesion.bssh.impl.util; 5 6 /*** 7 * @author schulzs 8 */ 9 public class CacheEntry<K, E> { 10 11 private final K key; 12 13 private E value; 14 15 private long lastAccessTime; 16 17 public CacheEntry(final K key, final E value) { 18 this.key = key; 19 this.value = value; 20 } 21 22 public K getKey() { 23 return key; 24 } 25 26 protected void setValue(final E value) { 27 this.value = value; 28 } 29 30 public E getValue() throws InstantiationException { 31 lastAccessTime = System.currentTimeMillis(); 32 return value; 33 } 34 35 public long getLastAccessTime() { 36 return lastAccessTime; 37 } 38 39 public int hashCode() { 40 return key.hashCode(); 41 } 42 43 public boolean equals(final Object o) { 44 if (o == null || !(o instanceof CacheEntry)) { 45 return false; 46 } 47 CacheEntry other = (CacheEntry) o; 48 return (this.getKey().equals(other.getKey())); 49 } 50 51 }