class ServiceProvision {

    public static <E extends RetryPolicy> Optional<E> loadRetryPolicy(
            Configuration configuration,
            Environment environment,
            String key,
            Class<? extends E> serviceClass) {
        return configuration
                .get(key, ServiceFactoryConfig.class)
                .map(factoryConfig -> {
                    RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class);
                    JsonNodeConfig config = factoryConfig.config();

                    return serviceClass.cast(factory.create(environment, config));
                });
    }

    private  ServiceProvision();

}