1
votes

Can I ever get Objectify to return a Set<> or must it always be a List<>? And if sets are possible, then can I do

@Entity
public class A{
  ...
  private Set<Key<B>> myBs; // where B is an entity, of course?

  private SortedSet<Key<D>> myDs;// where D is an entity, of course?
}
1

1 Answers

2
votes

Yes, you can, and Objectify will create "the obvious" choice for concrete implementation. But it's much better if you initialize the collection yourself and let Objectify recycle it. This way you can specify comparators, etc:

private SortedSet<Thing> things = new TreeSet<>(new FunkyComparator());

Objectify will clear and load the collection.

A lot more can be found under the subheading of Collections:

https://github.com/objectify/objectify/wiki/Entities