// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
// 
//     /**
//      * Build SQL query string
//      *
//      * @return SQL query
//      */
//     String getSQL();
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
// 
// }


import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List;

    void setSelectQuery(SQLSelectQuery select) {
        this.select = select;
    }

    public static class Builder extends SQLSelectQuery.Builder {

        private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();

        @Override
        public SQLWithSelectQuery build() {
            internalQuery.setSelectQuery(super.build());
            return internalQuery;
        }

        @Override
        public String buildSQL() {
            return build().getSQL();
        }

        public Builder with(String name, Selectable as) {
            internalQuery.with(name, as);
            return this;
        }
    }

    private void with(String name, Selectable as) {
        ctes.add(new CTE(name, as));
    }

// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLLang.java
// public interface SQLLang extends Cloneable {
// 
//     /**
//      * Build SQL query string
//      *
//      * @return SQL query
//      */
//     String getSQL();
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Selectable.java
// public interface Selectable extends SQLLang {
// 
// }


// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLWithSelectQuery.java
import org.mariotaku.sqliteqb.library.SQLLang;
import org.mariotaku.sqliteqb.library.Selectable;
import java.util.ArrayList;
import java.util.List;


    void setSelectQuery(SQLSelectQuery select) {
        this.select = select;
    }

    public static class Builder extends SQLSelectQuery.Builder {

        private final SQLWithSelectQuery internalQuery = new SQLWithSelectQuery();

        @Override
        public SQLWithSelectQuery build() {
            internalQuery.setSelectQuery(super.build());
            return internalQuery;
        }

        @Override
        public String buildSQL() {
            return build().getSQL();
        }

        public Builder with(String name, Selectable as) {
            internalQuery.with(name, as);
            return this;
        }
    }

    private void with(String name, Selectable as) {
        ctes.add(new CTE(name, as));
    }

    static class CTE implements SQLLang {