/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.shardingsphere.core.parsing.parser.token;

import lombok.Getter;
import org.apache.shardingsphere.core.parsing.lexer.token.DefaultKeyword;
import org.apache.shardingsphere.core.parsing.parser.expression.SQLExpression;
import org.apache.shardingsphere.core.rule.DataNode;

import java.util.LinkedList;
import java.util.List;

/**
 * Insert values token.
 *
 * @author maxiaoguang
 * @author panjuan
 */
@Getter
public final class InsertValuesToken extends SQLToken {
    
    private final DefaultKeyword type;
    
    private final List<String> columnNames = new LinkedList<>();
    
    private final List<InsertColumnValue> columnValues = new LinkedList<>();
    
    public InsertValuesToken(final int startIndex, final DefaultKeyword type) {
        super(startIndex);
        this.type = type;
    }
    
    /**
     * Add insert column value.
     *
     * @param columnValues column values
     * @param columnParameters  column parameters
     */
    public void addInsertColumnValue(final List<SQLExpression> columnValues, final List<Object> columnParameters) {
        InsertColumnValue result = new InsertColumnValue();
        result.values.addAll(columnValues);
        result.parameters.addAll(columnParameters);
        this.columnValues.add(result);
    }
    
    @Getter
    public final class InsertColumnValue {
    
        private final List<SQLExpression> values = new LinkedList<>();
        
        private final List<Object> parameters = new LinkedList<>();
    
        private final List<DataNode> dataNodes = new LinkedList<>();
    }
}

@@ -858,16 +858,104 @@
 token;%0A%0A
+import com.google.common.base.Predicate;%0Aimport com.google.common.collect.Collections2;%0A
 import l
@@ -968,16 +968,16 @@
 Getter;%0A
-
 import o
@@ -1121,16 +1121,189 @@
 ession;%0A
+import org.apache.shardingsphere.core.parsing.parser.expression.SQLPlaceholderExpression;%0Aimport org.apache.shardingsphere.core.parsing.parser.expression.SQLTextExpression;%0A
 import o
@@ -1348,16 +1348,44 @@
 aNode;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -2592,24 +2592,24 @@
 t%3C%3E();%0A    %0A
-
         priv
@@ -2661,20 +2661,946 @@
 edList%3C%3E();%0A
+        %0A        public void updateColumnValue(final int valueIndex, final String columnValue) %7B%0A            SQLExpression sqlExpression = values.get(valueIndex);%0A            if (sqlExpression instanceof SQLPlaceholderExpression) %7B%0A                parameters.set(getParameterIndex(sqlExpression), columnValue);%0A            %7D else %7B%0A                values.set(valueIndex, new SQLTextExpression(columnValue));%0A            %7D%0A        %7D%0A    %0A        private int getParameterIndex(final SQLExpression sqlExpression) %7B%0A            List%3CSQLExpression%3E sqlPlaceholderExpressions = new ArrayList%3C%3E(Collections2.filter(values, new Predicate%3CSQLExpression%3E() %7B%0A%0A                @Override%0A                public boolean apply(final SQLExpression input) %7B%0A                    return input instanceof SQLPlaceholderExpression;%0A                %7D%0A            %7D));%0A            return sqlPlaceholderExpressions.indexOf(sqlExpression);%0A        %7D%0A
     %7D%0A%7D%0A

add updateColumnValue()