Search code examples
javaprotocol-buffersdialogflow-es

How to add FieldMask of unknown field '21' in Java


I'm using dialogflow-es with Java library(v2).

And I found that Intent object doesn't have the method of "Set this intent as end of conversation".

I found that field's name of 'end of conversation' is 21, and value is 1.

So, I created the UnknownFieldSet and FieldMask with .addPaths("unknown_fields").

But after update intent, nothing was changed.

When I remove .setFieldMask(FieldMask fieldMask) from update intent, value was changed.

How can I change unknown field 21 with FieldMask?

UnknownFieldSet unknownFieldSet = UnknownFieldSet.newBuilder()
        .addField(21, Field.newBuilder().addVarint(1).build())
        .build();

FieldMask updateFieldMask = FieldMask.newBuilder()
        .addPaths("unknown_fields")
        .build();

Intent updateIntent = Intent.newBuilder()
        .setName(newIntent.getName())
        .setUnknownFields(unknownFieldSet)
        .build();

Solution

  • It sound like you're looking for FieldMaskUtil.merge and FieldMaskUtil.fromFieldNumbers.

    If that doesn't work, then what you're doing may just be impossible -- to do it with FieldMask instead of with field numbers directly.