/*
 * 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.rewrite.placeholder;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.optimize.result.insert.InsertOptimizeResultUnit;

import java.util.Collection;
import java.util.List;

/**
 * Insert values placeholder for rewrite.
 *
 * @author maxiaoguang
 * @author panjuan
 */
@RequiredArgsConstructor
@Getter
public final class InsertValuesPlaceholder implements ShardingPlaceholder {
    
    private final String logicTableName;
    
    private final Collection<String> columnNames;
    
    private final List<InsertOptimizeResultUnit> units;
}

@@ -857,16 +857,54 @@
 older;%0A%0A
+import com.google.common.base.Joiner;%0A
 import l
@@ -913,24 +913,24 @@
 bok.Getter;%0A
-
 import lombo
@@ -1042,16 +1042,129 @@
 ultUnit;
+%0Aimport org.apache.shardingsphere.core.route.type.TableUnit;%0Aimport org.apache.shardingsphere.core.rule.DataNode;
 %0A%0Aimport
@@ -1208,16 +1208,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0A/**%0A *
@@ -1538,24 +1538,24 @@
 Names;%0A    %0A
-
     private 
@@ -1598,10 +1598,1157 @@
  units;%0A
+    %0A    public String toString(final TableUnit tableUnit, final Map%3CString, String%3E logicAndActualTableMap) %7B%0A        StringBuilder result = new StringBuilder();%0A        result.append(%22 (%22).append(Joiner.on(%22, %22).join(columnNames)).append(%22) VALUES %22);%0A        appendUnits(tableUnit, result);%0A        result.delete(result.length() - 2, result.length());%0A        return result.toString();%0A    %7D%0A    %0A    private void appendUnits(final TableUnit tableUnit, final StringBuilder result) %7B%0A        for (InsertOptimizeResultUnit each : units) %7B%0A            if (isToAppendInsertOptimizeResult(tableUnit, each)) %7B%0A                result.append(each).append(%22, %22);%0A            %7D%0A        %7D%0A    %7D%0A    %0A    private boolean isToAppendInsertOptimizeResult(final TableUnit tableUnit, final InsertOptimizeResultUnit unit) %7B%0A        if (unit.getDataNodes().isEmpty() %7C%7C null == tableUnit) %7B%0A            return true;%0A        %7D%0A        for (DataNode each : unit.getDataNodes()) %7B%0A            if (tableUnit.getRoutingTable(each.getDataSourceName(), each.getTableName()).isPresent()) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A
 %7D%0A

add toString()