/*
 * Yet Another UserAgent Analyzer
 * Copyright (C) 2013-2022 Niels Basjes
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package nl.example;

import nl.basjes.parse.useragent.UserAgent;
import nl.basjes.parse.useragent.UserAgentAnalyzer;
import org.apache.commons.collections4.map.LRUMap;
import java.util.Collections;

public class Demo {

    private final UserAgentAnalyzer uaa;

    public Demo() {
        uaa = UserAgentAnalyzer
            .newBuilder()
            .withCache(1234)
            .withField("DeviceClass")
            .withAllFields()
            // Caffeine is a Java 11+ library.
            // This is one is Java 8 compatible.
            .withCacheInstantiator(
                cacheSize -> Collections.synchronizedMap(new LRUMap<>(cacheSize))
            )
            .build();
    }

    public UserAgent parse(String userAgent) {
        return uaa.parse(userAgent);
    }

}

@@ -1129,175 +1129,35 @@
     
-// This is one is Java 8 compatible.%0A            .withCacheInstantiator(%0A                cacheSize -%3E Collections.synchronizedMap(new LRUMap%3C%3E(cacheSize))%0A            
+.useJava8CompatibleCaching(
 )%0A  

Improve demo application