java.lang.Object
com.github.mizosoft.methanol.CacheControl
A group of
cache directives.
CacheControl
provides type-safe accessors for the directives specified in RFC 7234. Additionally, there's
support for the stale-while-revalidate
& stale-if-error
extensions
specified in RFC 5861. Other
Cache-Control
extensions can be accessed using the directives()
map.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A builder ofCacheControl
instances, with explicit directive setters for request cache directives. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether themax-stale
directive is present but has no value, which indicates that a response with any staleness is acceptable.Returns a map of all directives and their arguments.static CacheControl
empty()
Returns aCacheControl
with no directives.boolean
int
hashCode()
boolean
Returnstrue
if theprivate
directive is set.boolean
isPublic()
Returnstrue
if thepublic
directive is set.maxAge()
Returns the value of themax-age
directive if present.maxStale()
Returns the value of themax-stale
directive if present.minFresh()
Returns the value of themin-fresh
directive if present.boolean
Returnstrue
if themust-revalidate
directive is set.static CacheControl.Builder
Returns a newBuilder
.boolean
noCache()
Returnstrue
if theno-cache
directive is set.Returns the header fields nominated byno-cache
if specified.boolean
noStore()
Returnstrue
if theno-store
directive is set.Returns the header fields nominated byno-store
if specified.boolean
Returnstrue
if theno-transform
directive is set.boolean
Returnstrue
if theonly-if-cached
directive is set.static CacheControl
Parses the cache directives specified by the given value.static CacheControl
parse
(HttpHeaders headers) Parses the cache directives specified by the given headers.static CacheControl
Parses the cache directives specified by each of the given values.Returns the header fields nominated byprivate
if specified.boolean
Returnstrue
if theproxy-revalidate
directive is set.sMaxAge()
Returns the value of thes-maxage
directive if present.Returns the value of thestale-if-error
directive if present.Returns the value of thestale-while-revalidate
directive if present.toString()
-
Method Details
-
directives
Returns a map of all directives and their arguments. Directives that don't have arguments are mapped to an empty string. -
maxAge
Returns the value of themax-age
directive if present. -
sMaxAge
Returns the value of thes-maxage
directive if present. -
minFresh
Returns the value of themin-fresh
directive if present. -
maxStale
Returns the value of themax-stale
directive if present. -
anyMaxStale
public boolean anyMaxStale()Returns whether themax-stale
directive is present but has no value, which indicates that a response with any staleness is acceptable. -
staleWhileRevalidate
Returns the value of thestale-while-revalidate
directive if present. -
staleIfError
Returns the value of thestale-if-error
directive if present. -
noCache
public boolean noCache()Returnstrue
if theno-cache
directive is set. -
noCacheFields
Returns the header fields nominated byno-cache
if specified. -
noStore
public boolean noStore()Returnstrue
if theno-store
directive is set. -
noStoreFields
Returns the header fields nominated byno-store
if specified. -
noTransform
public boolean noTransform()Returnstrue
if theno-transform
directive is set. -
isPublic
public boolean isPublic()Returnstrue
if thepublic
directive is set. -
isPrivate
public boolean isPrivate()Returnstrue
if theprivate
directive is set. -
privateFields
Returns the header fields nominated byprivate
if specified. -
onlyIfCached
public boolean onlyIfCached()Returnstrue
if theonly-if-cached
directive is set. -
mustRevalidate
public boolean mustRevalidate()Returnstrue
if themust-revalidate
directive is set. -
proxyRevalidate
public boolean proxyRevalidate()Returnstrue
if theproxy-revalidate
directive is set. -
equals
-
hashCode
public int hashCode() -
toString
-
parse
Parses the cache directives specified by the given value.- Throws:
IllegalArgumentException
- if the given value has invalid cache directives
-
parse
Parses the cache directives specified by each of the given values.- Throws:
IllegalArgumentException
- if any of the given values has invalid cache directives
-
parse
Parses the cache directives specified by the given headers.- Throws:
IllegalArgumentException
- if the given headers have any invalid cache directives
-
newBuilder
Returns a newBuilder
. -
empty
Returns aCacheControl
with no directives.
-