}
private ConstructorDeclaration createConstructor() {
List<Expression> arguments = Lists.create();
for (CompiledOrder order : orderingInfo) {
Expression arg = order.getTarget().createNewInstance(t(order.getTarget().getType()));
if (order.isAscend() == false) {
arg = new TypeBuilder(factory, t(InvertOrder.class))
.newObject(arg)
.toExpression();
}
arguments.add(arg);
}
List<Statement> statements = Lists.create();
statements.add(factory.newSuperConstructorInvocation(arguments));
int position = 0;
for (CompiledOrder order : orderingInfo) {
Expression obj = new ExpressionBuilder(factory, factory.newThis())
.method("get", Models.toLiteral(factory, position))
.toExpression();
if (order.isAscend() == false) {
Expression invert = factory.newParenthesizedExpression(new ExpressionBuilder(factory, obj)
.castTo(t(InvertOrder.class))
.toExpression());
obj = new ExpressionBuilder(factory, invert)
.method("getEntity")
.toExpression();