BTW, this was already broken, but this seems like a very late and inefficient place to be testing that the sort direction is invalid -- it should be caught immediately in the json deserialization and an exception thrown there, instead. Here, instead of the else if, after we know that dir != SORT_DIRECTION_TYPE_ASC, we should just assert (dir == SORT_DIRECTION_TYPE_DESC).