I am using Google Cloud Endpoints with Objectify to create a Java backend to my mobile application. Everything works great except that the full JSON tree is being returned even when I use Objectify load groups. For example, a subset of the tree includes a Building class that has an Address and a list of Floors:
public class Building {
@Load(Everything.class)
private Ref<Address> address;
@Load(Lite.class})
private List<Ref<Floor>> floors = new ArrayList<Ref<Floor>>();
public Address getAddress() {
return Deref.deref(address);
}
public List<Floor> getFloors() {
return Deref.deref(floors);
}
}
public class BuildingEndpoint {
@ApiMethod(name = "building.getLite", path = "building_get_lite")
public Building getLite(@Named("id") Long id) {
Building building = ofy().load().group(Lite.class).type(Building.class).id(id).now();
return building;
}
}
According to the Objectify docs, the Address should be loading but NOT the Floors, however, everything is being loaded (as well as children classes of the Floor, all the way down in the object hierarchy).
Just in case the Deref is the issue, I'm including it here:
public class Deref {
public static class Func<T> implements Function<Ref<T>, T> {
public static Func<Object> INSTANCE = new Func<Object>();
@Override
public T apply(Ref<T> ref) {
return deref(ref);
}
}
public static <T> T deref(Ref<T> ref) {
return ref == null ? null : ref.get();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> List<T> deref(List<Ref<T>> reflist) {
return Lists.transform(reflist, (Func)Func.INSTANCE);
}
}
Any insights as to why load groups is not working and the FULL object hierarchy is still being loaded is much appreciated.