@Override
    public <T> Optional<T> convert(String rawContent, Class<T> clazz) {
        if (StringUtils.isBlank(rawContent)) {
            return Optional.empty();
        }
        try {
            return Optional.of(yaml.loadAs(rawContent, clazz));
        } catch (YAMLException ex) {
            LOGGER.log(Level.WARNING, String.format(Locale.ENGLISH, "Can not convert content [%s] to LoadbalancerRule",
                    rawContent), ex);
        }
        return Optional.empty();
    }
@Test
    public void test() {
        final RuleConverter yamlRuleConverter = new YamlRuleConverter();
        final Optional<LoadbalancerRule> convert = yamlRuleConverter
                .convert("rule: Random\nserviceName: test", LoadbalancerRule.class);
        Assert.assertTrue(convert.isPresent());
        assertEquals("Random", convert.get().getRule());
        assertEquals("test", convert.get().getServiceName());

        final Optional<Map> foo = yamlRuleConverter.convert(getMatchGroup("foo"), Map.class);
        Assert.assertTrue(foo.isPresent());
        Map<String, Object> map = foo.get();
        final Object matches = map.get("matches");
        Assert.assertTrue(matches instanceof List);
        Assert.assertTrue(((List<?>) matches).size() > 0);
        final Object content = ((List<?>) matches).get(0);
        Assert.assertTrue(content instanceof Map);
        final Object serviceName = ((Map<?, ?>) content).get("serviceName");
        Assert.assertEquals(serviceName, "foo");
    }