static <T> T getInstance(Annotation annotation, Class<T> expectedType) {
        try {
            @SuppressWarnings("unchecked")
            final Class<? extends T> clazz = (Class<? extends T>) invokeValueMethod(annotation);
            return expectedType.cast(instanceCache.computeIfAbsent(clazz, type -> {
                try {
                    return getInstance0(clazz);
                } catch (Exception e) {
                    throw new IllegalStateException(
                            "A class specified in @" + annotation.getClass().getSimpleName() +
                            " annotation must have an accessible default constructor: " + clazz.getName(), e);
                }
            }));
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(
                    "A class specified in @" + annotation.getClass().getSimpleName() +
                    " annotation cannot be cast to " + expectedType, e);
        }
    }
static < T > T getInstance ( Annotation annotation , Class < T > expectedType ) { try { @ SuppressWarnings ( "unchecked" ) final Class < ? extends T > clazz = ( Class < ? extends T > ) invokeValueMethod ( annotation ) ; return expectedType . cast ( instanceCache . computeIfAbsent ( clazz , type -> { try { return getInstance0 ( clazz ) ; } catch ( Exception e ) { throw new IllegalStateException ( "A class specified in @" + annotation . getClass ( ) . getSimpleName ( ) + " annotation must have an accessible default constructor: " + clazz . getName ( ) , e ) ; } } ) ) ; } catch ( ClassCastException e ) { throw new IllegalArgumentException ( "A class specified in @" + annotation . getClass ( ) . getSimpleName ( ) + " annotation cannot be cast to " + expectedType , e ) ; } }
Returns a cached instance of the specified {@link Class} which is specified in the given
{@link Annotation}.