@Test(dataProvider = "valueOfData") public void valueOf(String value, boolean noCache, boolean noStore, boolean noTransform, boolean onlyIfCached, int maxAge, int maxStale, int minFresh, Map<String, Optional<String>> cacheExtension) { RequestCacheControl cacheControl = RequestCacheControl.valueOf(value); assertEquals(cacheControl.isNoCache(), noCache); assertEquals(cacheControl.isNoStore(), noStore); assertEquals(cacheControl.isNoTransform(), noTransform); assertEquals(cacheControl.isOnlyIfCached(), onlyIfCached); assertEquals(cacheControl.getCacheExtension(), cacheExtension == null ? ImmutableMap.of() : cacheExtension); assertEquals(cacheControl.getMaxAge(), maxAge); assertEquals(cacheControl.getMaxStale(), maxStale); assertEquals(cacheControl.getMinFresh(), minFresh); }
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; } catch (ParseException ex) { throw new IllegalArgumentException("Error parsing request cache control: value='" + value + "'", ex); } }
RequestCacheControl { 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; } catch (ParseException ex) { throw new IllegalArgumentException("Error parsing request cache control: value='" + value + "'", ex); } } }
RequestCacheControl { 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; } catch (ParseException ex) { throw new IllegalArgumentException("Error parsing request cache control: value='" + value + "'", ex); } }  }
RequestCacheControl { 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; } catch (ParseException ex) { throw new IllegalArgumentException("Error parsing request cache control: value='" + value + "'", ex); } }  static RequestCacheControl valueOf(String value); boolean isNoCache(); boolean isNoStore(); int getMaxAge(); int getMaxStale(); int getMinFresh(); boolean isNoTransform(); boolean isOnlyIfCached(); Map<String, Optional<String>> getCacheExtension(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
RequestCacheControl { 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; } catch (ParseException ex) { throw new IllegalArgumentException("Error parsing request cache control: value='" + value + "'", ex); } }  static RequestCacheControl valueOf(String value); boolean isNoCache(); boolean isNoStore(); int getMaxAge(); int getMaxStale(); int getMinFresh(); boolean isNoTransform(); boolean isOnlyIfCached(); Map<String, Optional<String>> getCacheExtension(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final RequestCacheControl DEFAULT; }