ClientCacheControl extends CacheControl { public static ClientCacheControl parse(String... directives) { return parse(ImmutableList.copyOf(requireNonNull(directives, "directives"))); } ClientCacheControl(boolean noCache, boolean noStore, boolean noTransform, long maxAgeSeconds,
                       boolean onlyIfCached, long maxStaleSeconds, long minFreshSeconds,
                       long staleWhileRevalidateSeconds, long staleIfErrorSeconds); static ClientCacheControl parse(String... directives); static ClientCacheControl parse(Iterable<String> directives); static ClientCacheControlBuilder builder(); @Override boolean isEmpty(); boolean onlyIfCached(); boolean hasMaxStale(); long maxStaleSeconds(); long minFreshSeconds(); long staleWhileRevalidateSeconds(); long staleIfErrorSeconds(); @Override ClientCacheControlBuilder toBuilder(); @Override String asHeaderValue(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); static final ClientCacheControl EMPTY; static final ClientCacheControl FORCE_NETWORK; static final ClientCacheControl FORCE_CACHE; }
@Test public void testParse() { assertThat(ClientCacheControl.parse("")).isEqualTo(ClientCacheControl.EMPTY); assertThat(ClientCacheControl.parse("proxy-revalidate, s-maxage=1")) .isEqualTo(ClientCacheControl.EMPTY); assertThat(ClientCacheControl.parse("no-cache, no-store, no-transform, only-if-cached, " + "max-age=1, max-stale=2, min-fresh=3, " + "stale-while-revalidate=4, stale-if-error=5")) .isEqualTo(ClientCacheControl.builder() .noCache() .noStore() .noTransform() .maxAgeSeconds(1) .onlyIfCached() .maxStaleSeconds(2) .minFreshSeconds(3) .staleWhileRevalidateSeconds(4) .staleIfErrorSeconds(5) .build()); assertThat(ClientCacheControl.parse("max-stale")) .isEqualTo(ClientCacheControl.builder().maxStale().build()); }