Package org.eclipse.hono.util
Class CacheDirective
java.lang.Object
org.eclipse.hono.util.CacheDirective
A helper for parsing and creating cache directives compliant with
RFC 2616, Section 14.9.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static CacheDirective
Parses a cache directive.long
Gets the maximum period of time for which a resource may be cached.int
hashCode()
boolean
Checks if this directive allows caching.static CacheDirective
maxAgeDirective
(long maxAge) Creates a new max-age directive.static CacheDirective
maxAgeDirective
(Duration maxAge) Creates a new max-age directive.static CacheDirective
Creates a new no-cache directive.toString()
Creates a string representation of this directive.
-
Method Details
-
maxAgeDirective
Creates a new max-age directive.- Parameters:
maxAge
- The maximum age in number of seconds.- Returns:
- The directive.
- Throws:
IllegalArgumentException
- if the given value is less or equal to zero.
-
maxAgeDirective
Creates a new max-age directive.- Parameters:
maxAge
- The maximum age.- Returns:
- The directive.
- Throws:
IllegalArgumentException
- if the given value is less or equal to zero seconds.
-
noCacheDirective
Creates a new no-cache directive.- Returns:
- The directive.
-
from
Parses a cache directive.- Parameters:
directive
- The directive to parse.- Returns:
- The cache directive or
null
if the directive cannot be parsed.
-
isCachingAllowed
public boolean isCachingAllowed()Checks if this directive allows caching.- Returns:
false
if caching is not allowed.
-
getMaxAge
public long getMaxAge()Gets the maximum period of time for which a resource may be cached.- Returns:
- The maximum age in seconds.
-
toString
Creates a string representation of this directive.The format follows the cache-directive defined in RFC 2616, Section 14.9.
-
hashCode
public int hashCode() -
equals
-