return withBuilder(field, action);
return withBuilder(field, action);
@Test public void nestedMapField() { ConfigSource.Builder builder = ConfigSource.newBuilder(SomeConfig.getDefaultInstance()); builder.withBuilder( NESTED_MAP_VALUE_FIELD, "X", builder.withBuilder( NESTED_MAP_VALUE_FIELD, "Y",
if (field.isMapField()) { for (final MapEntry<Object, Message> entry : (List<MapEntry<Object, Message>>) value) { withBuilder( field, entry.getKey(), withBuilder( field, null,
if (field.isMapField()) { for (final MapEntry<Object, Message> entry : (List<MapEntry<Object, Message>>) value) { withBuilder( field, entry.getKey(), withBuilder( field, null,
String nestedPath = appendToPath(path, keyObj); helper.checkAndAddPath(nestedPath, value, field); builder.withBuilder(field, keyObj, new ReadNodeBuildAction(helper, entry.getValueNode(), appendToPath(nestedPath, keyObj))); } else { builder.withBuilder(field, new ReadNodeBuildAction(helper, value, path));
ConfigSource.Builder builder = ConfigSource.newBuilder(SomeConfig.getDefaultInstance()); builder.setValue(STRING_VALUE_FIELD, null, "A", L1); builder.withBuilder( NESTED_CONFIG_FIELD, null, builder.withBuilder( NESTED_CONFIG_FIELD, null,
String nestedPath = appendToPath(path, keyObj); helper.checkAndAddPath(nestedPath, value, field); builder.withBuilder(field, keyObj, new ReadNodeBuildAction(helper, entry.getValueNode(), appendToPath(nestedPath, keyObj))); } else { builder.withBuilder(field, new ReadNodeBuildAction(helper, value, path));
@Test public void nestedSimpleField() { ConfigSource.Builder builder = ConfigSource.newBuilder(SomeConfig.getDefaultInstance()); builder.setValue(STRING_VALUE_FIELD, null, "Hello World", L1); builder.withBuilder( NESTED_CONFIG_FIELD, null, new BuildAction() { @Override public void accept(ConfigSource.Builder subBuilder) { subBuilder.setValue(NESTED_STRING_VALUE_FIELD, null, "Sub World", L2); } }); ConfigSource source = builder.build(); SomeConfig config = (SomeConfig) source.getConfig(); Truth.assertThat(config.getStringValue()).isEqualTo("Hello World"); Truth.assertThat(source.getLocation(config, STRING_VALUE_FIELD.getName(), null)).isEqualTo(L1); Truth.assertThat(config.getNestedConfig().getNestedStringValue()).isEqualTo("Sub World"); Truth.assertThat( source.getLocation(config.getNestedConfig(), NESTED_STRING_VALUE_FIELD.getName(), null)) .isEqualTo(L2); }