public static HttpCacheContext cast(final HttpContext context) {
        if (context == null) {
            return null;
        }
        if (context instanceof HttpCacheContext) {
            return (HttpCacheContext) context;
        } else if (context instanceof HttpClientContext) {
            return new Delegate((HttpClientContext) context);
        } else {
            return new Delegate(HttpClientContext.cast(context));
        }
    }
Casts the given generic {@link HttpContext} as {@link HttpCacheContext} or
throws an {@link IllegalStateException} if the given context is not suitable.

@since 5.4
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java