if (orderByParentNode == null) {
comparator = Stmt.loadLiteral(null);
}
else {
AnonymousClassStructureBuilder comparatorClassBuilder = ObjectBuilder.newInstanceOf(Comparator.class, context).extend();
BlockBuilder<AnonymousClassStructureBuilder> compareMethod = comparatorClassBuilder
.publicOverridesMethod("compare", Parameter.of(Object.class, "o1"), Parameter.of(Object.class, "o2"));
// create "lhs" and "rhs" local vars of the query's result type; cast and assign Object args
compareMethod
.append(Stmt.declareFinalVariable("lhs", resultType, Cast.to(resultType, Stmt.loadVariable("o1"))))