*/
public static RequestCacheControl valueOf(String value) {
checkNotNull(value);
try {
HttpHeaderReader reader = HttpHeaderReader.newInstance(value);
RequestCacheControl cacheControl = new RequestCacheControl();
ImmutableMap.Builder<String, Optional<String>> cacheExtension = ImmutableMap.builder();
while (reader.hasNext()) {
String directive = reader.nextToken();
if ("no-cache".equalsIgnoreCase(directive)) {
cacheControl._noCache = true;
} else if ("no-store".equalsIgnoreCase(directive)) {
cacheControl._noStore = true;
} else if ("max-stale".equalsIgnoreCase(directive)) {
cacheControl._maxStale = reader.hasNextSeparator('=', false)
? readDeltaSeconds(reader, directive)
: Integer.MAX_VALUE;
} else if ("max-age".equalsIgnoreCase(directive)) {
cacheControl._maxAge = readDeltaSeconds(reader, directive);
} else if ("min-fresh".equalsIgnoreCase(directive)) {
cacheControl._minFresh = readDeltaSeconds(reader, directive);
} else if ("no-transform".equalsIgnoreCase(directive)) {
cacheControl._noTransform = true;
} else if ("only-if-cached".equalsIgnoreCase(directive)) {
cacheControl._onlyIfCached = true;
} else {
String directiveValue = null;
if (reader.hasNextSeparator('=', false)) {
reader.nextSeparator('=');
directiveValue = reader.nextTokenOrQuotedString();
}
cacheExtension.put(directive.toLowerCase(), Optional.fromNullable(directiveValue));
}
if (reader.hasNextSeparator(',', true)) {
reader.nextSeparator(',');
}
}
cacheControl._cacheExtension = cacheExtension.build();
return cacheControl;