I'm trying to implement a Queue with Objectify:
void addQueue(String bucket, String value){
Long next = ofy().load().type(OfyQueue.class)
.order("-id").first().get().getId();
OfyQueue q = new OfyQueue(bucket, value, next);
ofy().save().entity(q).now();
}
void removeQueue(String bucket, String value){
OfyQueue q = ofy().load().type(OfyQueue.class)
.filter("value", value).order("-id").first().get();
ofy().delete().entity(q);
}
There's something wrong with this code:
next
might be null? So when I create a newOfyQueue
it will pass a null value- in the removeQuery method, q might be null too, do I need to explicitly test if q is null or ofy().delete().entity will just ignore null values pass to it