All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infomaximum.cluster.utils.ExpireObject Maven / Gradle / Ivy

There is a newer version: 1.1.8p9
Show newest version
package com.infomaximum.cluster.utils;

import java.time.Duration;

public class ExpireObject {

    private final T object;
    private long timeUpdate;

    public ExpireObject(T object) {
        this.object = object;
        this.timeUpdate = System.currentTimeMillis();
    }

    public T get() {
        this.timeUpdate = System.currentTimeMillis();
        return object;
    }

    public boolean isExpire(Duration expire) {
        return ((System.currentTimeMillis() - timeUpdate) > expire.toMillis());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy