package com.cmobile.unifiedtms.entity.misc; public class ExpirableObject { private long storageTime = -1L; private long expiryTime = -1L; private T object; public ExpirableObject(T object, long expiryTime) { this.object = object; this.expiryTime = expiryTime; this.storageTime = System.currentTimeMillis(); } public T getObject() { if(!isExpired()) { return object; } return null; } public boolean isExpired() { long current = System.currentTimeMillis(); return (current > (this.storageTime + this.expiryTime)); } }