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

com.aliyun.auth.credentials.utils.RefreshResult Maven / Gradle / Ivy

The newest version!
package com.aliyun.auth.credentials.utils;

import java.time.Instant;

public final class RefreshResult {
    private final T value;
    private final Instant staleTime;
    private final Instant prefetchTime;

    private RefreshResult(Builder builder) {
        this.value = builder.value;
        this.staleTime = builder.staleTime;
        this.prefetchTime = builder.prefetchTime;
    }

    public static  Builder builder(T value) {
        return new Builder<>(value);
    }

    public T value() {
        return value;
    }

    public Instant staleTime() {
        return staleTime;
    }

    public Instant prefetchTime() {
        return prefetchTime;
    }

    public static final class Builder {
        private final T value;
        private Instant staleTime = Instant.MAX;
        private Instant prefetchTime = Instant.MAX;

        private Builder(T value) {
            this.value = value;
        }

        public Builder staleTime(Instant staleTime) {
            this.staleTime = staleTime;
            return this;
        }

        public Builder prefetchTime(Instant prefetchTime) {
            this.prefetchTime = prefetchTime;
            return this;
        }

        public RefreshResult build() {
            return new RefreshResult<>(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy