- java.lang.Object
-
- com.github.mizosoft.methanol.CacheControl.Builder
-
- Enclosing class:
- CacheControl
public static final class CacheControl.Builder extends java.lang.ObjectA builder ofCacheControlinstances, with explicit directive setters for request cache directives.Methods that accept a
Durationdrop any precision finer than that of a second, which is the only precision allowed by cache directives representing durations. Additionally, any duration with number of seconds that's larger thanInteger.MAX_VALUEis truncated to that value.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CacheControl.BuilderanyMaxStale()Sets themax-staledirective to accept any stale response.CacheControlbuild()Builds a newCache-Control.CacheControl.Builderdirective(java.lang.String directive)Sets the given directive with no argument.CacheControl.Builderdirective(java.lang.String directive, java.lang.String argument)Sets the given directive to the given argument.CacheControl.BuildermaxAge(java.time.Duration maxAge)Sets themax-agedirective to the given duration.CacheControl.BuildermaxStale(java.time.Duration maxStale)Sets themax-staledirective to the given duration.CacheControl.BuilderminFresh(java.time.Duration minFresh)Sets themin-freshdirective to the given duration.CacheControl.BuildernoCache()Sets theno-cachedirective.CacheControl.BuildernoStore()Sets theno-storedirective.CacheControl.BuildernoTransform()Sets theno-transformdirective.CacheControl.BuilderonlyIfCached()Sets theonly-if-cacheddirective.CacheControl.BuilderstaleIfError(java.time.Duration staleIfError)Sets thestale-if-errordirective to the given duration.
-
-
-
Method Detail
-
directive
@CanIgnoreReturnValue public CacheControl.Builder directive(java.lang.String directive)
Sets the given directive with no argument.- Throws:
java.lang.IllegalArgumentException- ifdirectiveis invalid
-
directive
@CanIgnoreReturnValue public CacheControl.Builder directive(java.lang.String directive, java.lang.String argument)
Sets the given directive to the given argument. Ifargumentis an empty string, the directive is considered one without argument.- Throws:
java.lang.IllegalArgumentException- if either ofdirectiveorargumentis invalid
-
maxAge
@CanIgnoreReturnValue public CacheControl.Builder maxAge(java.time.Duration maxAge)
Sets themax-agedirective to the given duration.- Throws:
java.lang.IllegalArgumentException- IfmaxAgedoesn't contain a positive number of seconds
-
minFresh
@CanIgnoreReturnValue public CacheControl.Builder minFresh(java.time.Duration minFresh)
Sets themin-freshdirective to the given duration.- Throws:
java.lang.IllegalArgumentException- IfminFreshdoesn't contain a positive number of seconds
-
maxStale
@CanIgnoreReturnValue public CacheControl.Builder maxStale(java.time.Duration maxStale)
Sets themax-staledirective to the given duration.- Throws:
java.lang.IllegalArgumentException- IfmaxStaledoesn't contain a positive number of seconds
-
anyMaxStale
@CanIgnoreReturnValue public CacheControl.Builder anyMaxStale()
Sets themax-staledirective to accept any stale response.
-
staleIfError
@CanIgnoreReturnValue public CacheControl.Builder staleIfError(java.time.Duration staleIfError)
Sets thestale-if-errordirective to the given duration.- Throws:
java.lang.IllegalArgumentException- IfstaleIfErrordoesn't contain a positive number of seconds
-
noCache
@CanIgnoreReturnValue public CacheControl.Builder noCache()
Sets theno-cachedirective.
-
noStore
@CanIgnoreReturnValue public CacheControl.Builder noStore()
Sets theno-storedirective.
-
noTransform
@CanIgnoreReturnValue public CacheControl.Builder noTransform()
Sets theno-transformdirective.
-
onlyIfCached
@CanIgnoreReturnValue public CacheControl.Builder onlyIfCached()
Sets theonly-if-cacheddirective.
-
build
public CacheControl build()
Builds a newCache-Control.
-
-