class ConnectorOptions {

    public static <T> T extractOptionAndMap(Map<String, ?> options, String key,
                                                                    Function<? super String, T> mappingFn, T defaultValue) {
        if (options == null) {
            return defaultValue;
        }

        try {
            return Optional.ofNullable(options.get(key))
                        .map(Object::toString)
                        .filter(v -> v.length() > 0)
                        .map(mappingFn)
                        .orElse(defaultValue);
        } catch (Exception ex) {
            LOG.error("Evaluation of option '" + key + "' failed. Returning default value.", ex);
            return defaultValue;
        }
    }

    private  ConnectorOptions();

}