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

restx.http.CacheControl Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package restx.http;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import restx.RestxResponse;

/**
 * Date: 22/5/14
 * Time: 18:47
 */
public class CacheControl {
    public static final CacheControl MUST_REVALIDATE = new CacheControl(-1, ImmutableList.of("must-revalidate"));

    private final int expires;
    private final ImmutableList cacheControl;

    public CacheControl(int expires, ImmutableList cacheControl) {
        this.expires = expires;
        this.cacheControl = cacheControl;
    }

    public int getExpires() {
        return expires;
    }

    public ImmutableList getCacheControl() {
        return cacheControl;
    }

    @Override
    public String toString() {
        return "CacheControl{" +
                "expires=" + expires +
                ", cacheControl=" + cacheControl +
                '}';
    }

    public void writeTo(RestxResponse resp) {
        resp.setHeader("Expires", String.valueOf(expires));
        resp.setHeader("Cache-Control", Joiner.on(", ").join(cacheControl));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy