initial import
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
package com.cmobile.unifiedtms.entity.misc;
|
||||
|
||||
public class ExpirableObject<T> {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user