// Path: library/src/main/java/org/mariotaku/sqliteqb/library/OnConflict.java
// public enum OnConflict {
//     ROLLBACK("ROLLBACK"), ABORT("ABORT"), REPLACE("REPLACE"), FAIL("FAIL"), IGNORE("IGNORE");
//     private final String action;
// 
//     OnConflict(final String action) {
//         this.action = action;
//     }
// 
//     public String getAction() {
//         return action;
//     }
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
// 
//     public static String toString(final Object[] array, final char token, final boolean includeSpace) {
//         final StringBuilder builder = new StringBuilder();
//         final int length = array.length;
//         for (int i = 0; i < length; i++) {
//             final String string = objectToString(array[i]);
//             if (string != null) {
//                 if (i > 0) {
//                     builder.append(includeSpace ? token + " " : token);
//                 }
//                 builder.append(string);
//             }
//         }
//         return builder.toString();
//     }
// 
//     public static String toStringForSQL(final int size) {
//         final StringBuilder builder = new StringBuilder();
//         for (int i = 0; i < size; i++) {
//             if (i > 0) {
//                 builder.append(',');
//             }
//             builder.append('?');
//         }
//         return builder.toString();
//     }
// 
//     private static String objectToString(Object o) {
//         if (o instanceof SQLLang)
//             return ((SQLLang) o).getSQL();
//         return o != null ? o.toString() : null;
//     }
// 
//     public static String[] toStringArray(Object[] array) {
//         final String[] strings = new String[array.length];
//         final int length = array.length;
//         for (int i = 0; i < length; i++) {
//             strings[i] = objectToString(array[i]);
//         }
//         return strings;
//     }
// }


import org.mariotaku.sqliteqb.library.OnConflict;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils;
/*
 * Copyright (c) 2015 mariotaku
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mariotaku.sqliteqb.library.query;


public class SQLInsertQuery implements SQLQuery {

    private OnConflict onConflict;
    private String table;
    private String[] columns;
    private String values;

    SQLInsertQuery() {

    }

    @Override
    public String getSQL() {
        if (table == null) throw new NullPointerException("table must not be null!");
        final StringBuilder sb = new StringBuilder();
        sb.append("INSERT ");
        if (onConflict != null) {
            sb.append("OR ");
            sb.append(onConflict.getAction());
            sb.append(" ");
        }
        sb.append("INTO ");
        sb.append(table);
        sb.append(" (");
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/OnConflict.java
// public enum OnConflict {
//     ROLLBACK("ROLLBACK"), ABORT("ABORT"), REPLACE("REPLACE"), FAIL("FAIL"), IGNORE("IGNORE");
//     private final String action;
// 
//     OnConflict(final String action) {
//         this.action = action;
//     }
// 
//     public String getAction() {
//         return action;
//     }
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/SQLQuery.java
// public interface SQLQuery extends SQLLang {
// }
// 
// Path: library/src/main/java/org/mariotaku/sqliteqb/library/Utils.java
// public class Utils {
// 
//     public static String toString(final Object[] array, final char token, final boolean includeSpace) {
//         final StringBuilder builder = new StringBuilder();
//         final int length = array.length;
//         for (int i = 0; i < length; i++) {
//             final String string = objectToString(array[i]);
//             if (string != null) {
//                 if (i > 0) {
//                     builder.append(includeSpace ? token + " " : token);
//                 }
//                 builder.append(string);
//             }
//         }
//         return builder.toString();
//     }
// 
//     public static String toStringForSQL(final int size) {
//         final StringBuilder builder = new StringBuilder();
//         for (int i = 0; i < size; i++) {
//             if (i > 0) {
//                 builder.append(',');
//             }
//             builder.append('?');
//         }
//         return builder.toString();
//     }
// 
//     private static String objectToString(Object o) {
//         if (o instanceof SQLLang)
//             return ((SQLLang) o).getSQL();
//         return o != null ? o.toString() : null;
//     }
// 
//     public static String[] toStringArray(Object[] array) {
//         final String[] strings = new String[array.length];
//         final int length = array.length;
//         for (int i = 0; i < length; i++) {
//             strings[i] = objectToString(array[i]);
//         }
//         return strings;
//     }
// }


// Path: library/src/main/java/org/mariotaku/sqliteqb/library/query/SQLInsertQuery.java
import org.mariotaku.sqliteqb.library.OnConflict;
import org.mariotaku.sqliteqb.library.SQLQuery;
import org.mariotaku.sqliteqb.library.Utils;

/*
 * Copyright (c) 2015 mariotaku
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mariotaku.sqliteqb.library.query;


public class SQLInsertQuery implements SQLQuery {

    private OnConflict onConflict;
    private String table;
    private String[] columns;
    private String values;

    SQLInsertQuery() {

    }

    @Override
    public String getSQL() {
        if (table == null) throw new NullPointerException("table must not be null!");
        final StringBuilder sb = new StringBuilder();
        sb.append("INSERT ");
        if (onConflict != null) {
            sb.append("OR ");
            sb.append(onConflict.getAction());
            sb.append(" ");
        }
        sb.append("INTO ");
        sb.append(table);
        sb.append(" (");
        sb.append(Utils.toString(columns, ',', true));