class GridSqlElement implements GridSqlAst {
    /** */
    private final List<GridSqlAst> children;

    /** */
    private GridSqlType resultType;

    /**
     * @param children Initial child list.
     */
    protected GridSqlElement(List<GridSqlAst> children) {
        assert children != null;

        this.children = children;
    }

    /** {@inheritDoc} */
    @Override public GridSqlType resultType() {
        return resultType;
    }

    /**
     * @param type Optional expression result type (if this is an expression and result type is known).
     * @return {@code this}.
     */
    public GridSqlElement resultType(GridSqlType type) {
        resultType = type;

        return this;
    }

    /**
     * @param expr Expr.
     * @return {@code this}.
     */
    public GridSqlElement addChild(GridSqlAst expr) {
        if (expr == null)
            throw new NullPointerException();

        children.add(expr);

        return this;
    }

    /** {@inheritDoc} */
    @Override public <E extends GridSqlAst> E child() {
        return child(0);
    }

    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    @Override public <E extends GridSqlAst> E child(int idx) {
        return (E)children.get(idx);
    }

    /** {@inheritDoc} */
    @Override public <E extends GridSqlAst> void child(int idx, E child) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public int size() {
        return children.size();
    }

    /** {@inheritDoc} */
    @Override public String toString() {
        return getSQL();
    }

    /** {@inheritDoc} */
    @Override public int hashCode() {
        throw new IllegalStateException();
    }

    /** {@inheritDoc} */
    @Override public boolean equals(Object o) {
        return this == o || (!(o == null || getClass() != o.getClass()) &&
            children.equals(((GridSqlElement)o).children));
    }
}

        if (child == null)
            throw new NullPointerException();

        children.set(idx, child);
    
<no_super_class>