public static Map<String, Object> toValueMap(ReferenceMap m, Map<String, ValueReference> parameters) {
        final ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.builder();
        for (Map.Entry<String, Reference> entry : m.entrySet()) {
            final Object value = valueOf(entry.getValue(), parameters);
            if (value != null) {
                mapBuilder.put(entry.getKey(), value);
            }
        }
        return mapBuilder.build();
    }
@Test
    public void toValueMap() {
        final Map<String, ValueReference> parameters = ImmutableMap.<String, ValueReference>builder()
                .put("BOOLEAN", ValueReference.of(true))
                .put("FLOAT", ValueReference.of(1.0f))
                .put("INTEGER", ValueReference.of(42))
                .put("STRING", ValueReference.of("String"))
                .put("ENUM", ValueReference.of(TestEnum.A))
                .build();
        final ReferenceMap map = new ReferenceMap(ImmutableMap.<String, Reference>builder()
                .put("boolean", ValueReference.of(true))
                .put("param_boolean", ValueReference.createParameter("BOOLEAN"))
                .put("float", ValueReference.of(1.0f))
                .put("param_float", ValueReference.createParameter("FLOAT"))
                .put("integer", ValueReference.of(42))
                .put("param_integer", ValueReference.createParameter("INTEGER"))
                .put("string", ValueReference.of("String"))
                .put("param_string", ValueReference.createParameter("STRING"))
                .put("enum", ValueReference.of(TestEnum.A))
                .put("param_enum", ValueReference.createParameter("ENUM"))
                .put("list", new ReferenceList(ImmutableList.of(
                        ValueReference.of(1),
                        ValueReference.of(2.0f),
                        ValueReference.of("3"),
                        ValueReference.of(true),
                        ValueReference.createParameter("STRING"))))
                .put("nestedList", new ReferenceList(ImmutableList.of(
                        new ReferenceMap(ImmutableMap.of(
                                "k1", ValueReference.of("v1"),
                                "k2", ValueReference.of(2))),
                        new ReferenceMap(ImmutableMap.of(
                                "k1", ValueReference.of("v2"),
                                "k2", ValueReference.of(4))))))
                .put("map", new ReferenceMap(ImmutableMap.of(
                        "k1", ValueReference.of("v1"),
                        "k2", ValueReference.of(2),
                        "k3", ValueReference.createParameter("INTEGER"))))
                .build());
        final ImmutableMap<String, Object> expectedMap = ImmutableMap.<String, Object>builder()
                .put("boolean", true)
                .put("param_boolean", true)
                .put("float", 1.0f)
                .put("param_float", 1.0f)
                .put("integer", 42)
                .put("param_integer", 42)
                .put("string", "String")
                .put("param_string", "String")
                .put("enum", "A")
                .put("param_enum", "A")
                .put("list", ImmutableList.of(1, 2.0f, "3", true, "String"))
                .put("nestedList", ImmutableList.of(
                        ImmutableMap.of( "k1", "v1", "k2", 2),
                        ImmutableMap.of( "k1", "v2", "k2", 4)
                ))
                .put("map", ImmutableMap.of(
                        "k1", "v1",
                        "k2", 2,
                        "k3", 42))
                .build();

        final Map<String, Object> valueReferenceMap = ReferenceMapUtils.toValueMap(map, parameters);
        assertThat(valueReferenceMap).isEqualTo(expectedMap);
    }