Class CacheControl.Builder
java.lang.Object
com.github.mizosoft.methanol.CacheControl.Builder
- Enclosing class:
CacheControl
A builder of
CacheControl instances, with explicit directive setters for request cache
directives.
Methods that accept a Duration drop 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 than Integer.MAX_VALUE is truncated to
that value.
-
Method Summary
Modifier and TypeMethodDescriptionSets themax-staledirective to accept any stale response.build()Builds a newCache-Control.Sets the given directive with no argument.Sets the given directive to the given argument.Sets themax-agedirective to the given duration.Sets themax-staledirective to the given duration.Sets themin-freshdirective to the given duration.noCache()Sets theno-cachedirective.noStore()Sets theno-storedirective.Sets theno-transformdirective.Sets theonly-if-cacheddirective.staleIfError(Duration staleIfError) Sets thestale-if-errordirective to the given duration.
-
Method Details
-
directive
Sets the given directive with no argument.- Throws:
IllegalArgumentException- ifdirectiveis invalid
-
directive
Sets the given directive to the given argument. Ifargumentis an empty string, the directive is considered one without argument.- Throws:
IllegalArgumentException- if either ofdirectiveorargumentis invalid
-
maxAge
Sets themax-agedirective to the given duration.- Throws:
IllegalArgumentException- IfmaxAgedoesn't contain a positive number of seconds
-
minFresh
Sets themin-freshdirective to the given duration.- Throws:
IllegalArgumentException- IfminFreshdoesn't contain a positive number of seconds
-
maxStale
Sets themax-staledirective to the given duration.- Throws:
IllegalArgumentException- IfmaxStaledoesn't contain a positive number of seconds
-
anyMaxStale
Sets themax-staledirective to accept any stale response. -
staleIfError
Sets thestale-if-errordirective to the given duration.- Throws:
IllegalArgumentException- IfstaleIfErrordoesn't contain a positive number of seconds
-
noCache
Sets theno-cachedirective. -
noStore
Sets theno-storedirective. -
noTransform
Sets theno-transformdirective. -
onlyIfCached
Sets theonly-if-cacheddirective. -
build
Builds a newCache-Control.
-