- java.lang.Object
-
- com.github.mizosoft.methanol.CacheControl
-
public final class CacheControl extends java.lang.ObjectA group of cache directives.CacheControlprovides type-safe accessors for the directives specified in RFC 7234. Additionally, there's support for thestale-while-revalidate&stale-if-errorextensions specified in RFC 5861. OtherCache-Controlextensions can be accessed using thedirectives()map.- See Also:
- Caching - CacheControl for an overview of the semantics of supported cache directives.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCacheControl.BuilderA builder ofCacheControlinstances, with explicit directive setters for request cache directives.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleananyMaxStale()Returns whether themax-staledirective is present but has no value, which indicates that a response with any staleness is acceptable.java.util.Map<java.lang.String,java.lang.String>directives()Returns a map of all directives and their arguments.static CacheControlempty()Returns aCacheControlwith no directives.booleanequals(@Nullable java.lang.Object obj)inthashCode()booleanisPrivate()Returnstrueif theprivatedirective is set.booleanisPublic()Returnstrueif thepublicdirective is set.java.util.Optional<java.time.Duration>maxAge()Returns the value of themax-agedirective if present.java.util.Optional<java.time.Duration>maxStale()Returns the value of themax-staledirective if present.java.util.Optional<java.time.Duration>minFresh()Returns the value of themin-freshdirective if present.booleanmustRevalidate()Returnstrueif themust-revalidatedirective is set.static CacheControl.BuildernewBuilder()Returns a newBuilder.booleannoCache()Returnstrueif theno-cachedirective is set.java.util.Set<java.lang.String>noCacheFields()Returns the header fields nominated byno-cacheif specified.booleannoStore()Returnstrueif theno-storedirective is set.java.util.Set<java.lang.String>noStoreFields()Returns the header fields nominated byno-storeif specified.booleannoTransform()Returnstrueif theno-transformdirective is set.booleanonlyIfCached()Returnstrueif theonly-if-cacheddirective is set.static CacheControlparse(java.lang.String value)Parses the cache directives specified by the given value.static CacheControlparse(java.net.http.HttpHeaders headers)Parses the cache directives specified by the given headers.static CacheControlparse(java.util.List<java.lang.String> values)Parses the cache directives specified by each of the given values.java.util.Set<java.lang.String>privateFields()Returns the header fields nominated byprivateif specified.booleanproxyRevalidate()Returnstrueif theproxy-revalidatedirective is set.java.util.Optional<java.time.Duration>sMaxAge()Returns the value of thes-maxagedirective if present.java.util.Optional<java.time.Duration>staleIfError()Returns the value of thestale-if-errordirective if present.java.util.Optional<java.time.Duration>staleWhileRevalidate()Returns the value of thestale-while-revalidatedirective if present.java.lang.StringtoString()
-
-
-
Method Detail
-
directives
public java.util.Map<java.lang.String,java.lang.String> directives()
Returns a map of all directives and their arguments. Directives that don't have arguments are mapped to an empty string.
-
maxAge
public java.util.Optional<java.time.Duration> maxAge()
Returns the value of themax-agedirective if present.
-
sMaxAge
public java.util.Optional<java.time.Duration> sMaxAge()
Returns the value of thes-maxagedirective if present.
-
minFresh
public java.util.Optional<java.time.Duration> minFresh()
Returns the value of themin-freshdirective if present.
-
maxStale
public java.util.Optional<java.time.Duration> maxStale()
Returns the value of themax-staledirective if present.
-
anyMaxStale
public boolean anyMaxStale()
Returns whether themax-staledirective is present but has no value, which indicates that a response with any staleness is acceptable.
-
staleWhileRevalidate
public java.util.Optional<java.time.Duration> staleWhileRevalidate()
Returns the value of thestale-while-revalidatedirective if present.
-
staleIfError
public java.util.Optional<java.time.Duration> staleIfError()
Returns the value of thestale-if-errordirective if present.
-
noCache
public boolean noCache()
Returnstrueif theno-cachedirective is set.
-
noCacheFields
public java.util.Set<java.lang.String> noCacheFields()
Returns the header fields nominated byno-cacheif specified.
-
noStore
public boolean noStore()
Returnstrueif theno-storedirective is set.
-
noStoreFields
public java.util.Set<java.lang.String> noStoreFields()
Returns the header fields nominated byno-storeif specified.
-
noTransform
public boolean noTransform()
Returnstrueif theno-transformdirective is set.
-
isPublic
public boolean isPublic()
Returnstrueif thepublicdirective is set.
-
isPrivate
public boolean isPrivate()
Returnstrueif theprivatedirective is set.
-
privateFields
public java.util.Set<java.lang.String> privateFields()
Returns the header fields nominated byprivateif specified.
-
onlyIfCached
public boolean onlyIfCached()
Returnstrueif theonly-if-cacheddirective is set.
-
mustRevalidate
public boolean mustRevalidate()
Returnstrueif themust-revalidatedirective is set.
-
proxyRevalidate
public boolean proxyRevalidate()
Returnstrueif theproxy-revalidatedirective is set.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
parse
public static CacheControl parse(java.lang.String value)
Parses the cache directives specified by the given value.- Throws:
java.lang.IllegalArgumentException- if the given value has invalid cache directives
-
parse
public static CacheControl parse(java.util.List<java.lang.String> values)
Parses the cache directives specified by each of the given values.- Throws:
java.lang.IllegalArgumentException- if any of the given values has invalid cache directives
-
parse
public static CacheControl parse(java.net.http.HttpHeaders headers)
Parses the cache directives specified by the given headers.- Throws:
java.lang.IllegalArgumentException- if the given headers have any invalid cache directives
-
newBuilder
public static CacheControl.Builder newBuilder()
Returns a newBuilder.
-
empty
public static CacheControl empty()
Returns aCacheControlwith no directives.
-
-