Code example for ConcurrentMap

Methods: getput

    public <T extends Annotation> T get(Class<T> annotationType, Map<String, ?> values) {
        if (annotationType == null) {
            throw new IllegalArgumentException("Must specify an annotation");
        Class<?> clazz = cache.get(annotationType);
        // Not safe against data race, but doesn't matter, we can recompute and 
        // get the same value 
        if (clazz == null) {
            // create the proxy class 
            clazz = Proxy.getProxyClass(annotationType.getClassLoader(), annotationType, Serializable.class);
            cache.put(annotationType, clazz);
        AnnotationInvocationHandler handler = new AnnotationInvocationHandler(values, annotationType);
        // create a new instance by obtaining the constructor via relection 
        try { 
            return annotationType.cast(clazz.getConstructor(new Class[]{InvocationHandler.class}).newInstance(new Object[]{handler}));
        } catch (IllegalArgumentException e) {
            throw new IllegalStateException("Error instantiating proxy for annotation. Annotation type: " + annotationType, e);
        } catch (InstantiationException e) {
Connect your IDE to all the code out there  Get Codota for Java