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-stale
directive 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-age
directive to the given duration.Sets themax-stale
directive to the given duration.Sets themin-fresh
directive to the given duration.noCache()
Sets theno-cache
directive.noStore()
Sets theno-store
directive.Sets theno-transform
directive.Sets theonly-if-cached
directive.staleIfError
(Duration staleIfError) Sets thestale-if-error
directive to the given duration.
-
Method Details
-
directive
Sets the given directive with no argument.- Throws:
IllegalArgumentException
- ifdirective
is invalid
-
directive
Sets the given directive to the given argument. Ifargument
is an empty string, the directive is considered one without argument.- Throws:
IllegalArgumentException
- if either ofdirective
orargument
is invalid
-
maxAge
Sets themax-age
directive to the given duration.- Throws:
IllegalArgumentException
- IfmaxAge
doesn't contain a positive number of seconds
-
minFresh
Sets themin-fresh
directive to the given duration.- Throws:
IllegalArgumentException
- IfminFresh
doesn't contain a positive number of seconds
-
maxStale
Sets themax-stale
directive to the given duration.- Throws:
IllegalArgumentException
- IfmaxStale
doesn't contain a positive number of seconds
-
anyMaxStale
Sets themax-stale
directive to accept any stale response. -
staleIfError
Sets thestale-if-error
directive to the given duration.- Throws:
IllegalArgumentException
- IfstaleIfError
doesn't contain a positive number of seconds
-
noCache
Sets theno-cache
directive. -
noStore
Sets theno-store
directive. -
noTransform
Sets theno-transform
directive. -
onlyIfCached
Sets theonly-if-cached
directive. -
build
Builds a newCache-Control
.
-