protected MapLiteral buildStatusObj()

in src/main/java/org/apache/sling/scripting/sightly/impl/plugin/AbstractRepeatPlugin.java [45:63]


    protected MapLiteral buildStatusObj(String indexVar, String sizeVar) {
        HashMap<String, ExpressionNode> obj = new HashMap<>();
        Identifier indexId = new Identifier(indexVar);
        BinaryOperation firstExpr = new BinaryOperation(BinaryOperator.EQ, indexId, NumericConstant.ZERO);
        BinaryOperation lastExpr = new BinaryOperation(
                BinaryOperator.EQ,
                indexId,
                new BinaryOperation(BinaryOperator.SUB, new Identifier(sizeVar), NumericConstant.ONE));
        obj.put(INDEX, indexId);
        obj.put(COUNT, new BinaryOperation(BinaryOperator.ADD, indexId, NumericConstant.ONE));
        obj.put(FIRST, firstExpr);
        obj.put(
                MIDDLE,
                new UnaryOperation(UnaryOperator.NOT, new BinaryOperation(BinaryOperator.OR, firstExpr, lastExpr)));
        obj.put(LAST, lastExpr);
        obj.put(ODD, parityCheck(indexId, NumericConstant.ZERO));
        obj.put(EVEN, parityCheck(indexId, NumericConstant.ONE));
        return new MapLiteral(obj);
    }