ClientCacheControl extends CacheControl { public boolean onlyIfCached() { return onlyIfCached; } 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 testOnlyIfCached() { final ClientCacheControl cc = ClientCacheControl.builder().onlyIfCached().build(); assertThat(cc.onlyIfCached()).isTrue(); assertThat(cc.hasMaxStale()).isFalse(); assertThat(cc.maxStaleSeconds()).isEqualTo(-1); assertThat(cc.minFreshSeconds()).isEqualTo(-1); assertThat(cc.staleWhileRevalidateSeconds()).isEqualTo(-1); assertThat(cc.staleIfErrorSeconds()).isEqualTo(-1); assertThat(cc.asHeaderValue()).isEqualTo("only-if-cached"); assertThat(cc.toString()).isEqualTo("ClientCacheControl(only-if-cached)"); }