class OptionalConverter implements PropertyConverter<Optional> {

    @Override
    public Optional convert(String value, ConversionContext ctx) {
        if(value==null){
            return Optional.empty();
        }
        try{
            Type targetType = ctx.getTargetType().getType();
            ParameterizedType pt = (ParameterizedType) targetType;
            if(String.class.equals(pt.getActualTypeArguments()[0])){
                return Optional.of(value);
            }
            ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(pt.getActualTypeArguments()[0]));
            return Optional.ofNullable(ctx.getConfiguration().adapt(converter));
        }catch(Exception e){
            throw new ConfigException("Error evaluating config createValue.", e);
        }
    }

}