1

I can set a property to a new entity:

Entity.Builder builder = Entity.builder(actKey);
builder.set("name", someName);

I can see a method to add a list as a property:

List<Value<String>> aliases = new ArrayList<>();
builder.set("aliases", aliases);

I cannot find, however, how to create this Value<String>. There is a DatastoreHelper.makeValue() method in DatastoreV1, but it creates a different Value object.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58

1 Answers1

2

Looking at the source code for gcloud, the answer is this:

Builder aliases = ListValue.builder();
while (someIterator.hasNext()) {
    aliases.addValue(StringValue.builder("some string").build());
}
builder.set("aliases", aliases.build());
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • 1
    Correct. other options are: Using ListValue.of(....), and using the various EntityBulder.set method that accept list. – ozarov Apr 09 '16 at 19:42