/**
 * Copyright (C) 2006-2018 Talend Inc. - www.talend.com
 *
 * 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.talend.sdk.component.studio.model.parameter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.talend.core.model.process.IElement;

/**
 * Represents Table parameter. Table parameter is ElementParameter, which EParameterFieldType is TABLE
 * Value of Table parameter should have List<Map<String, Object>> type. Its value is a list of table records.
 * Each table record is represented by Map.
 * This class ensures Table parameter integrity. When user sets null or "" value to this parameter, empty list is set
 * instead
 */
public class TableElementParameter extends TaCoKitElementParameter {

    public TableElementParameter(final IElement element) {
        super(element);
    }

    /**
     * Sets value of this Table parameter. Expected type of value is List<Map<String, Object>>.
     * null and "" are also accepted. In this case empty list will be set as value
     * 
     * @param newValue new value to set
     */
    @Override
    public void setValue(final Object newValue) {
        if (newValue == null || "".equals(newValue)) {
            super.setValue(new ArrayList<Map<String, Object>>());
        } else if (!(newValue instanceof List)) {
            throw new IllegalArgumentException("newValue should be of List<Map<String, Object>> type");
        } else {
            super.setValue(newValue);
        }
    }

}

@@ -673,36 +673,8 @@
 r;%0A%0A
-import java.util.ArrayList;%0A
 impo
@@ -1152,16 +1152,155 @@
  instead
+. Also it implements convertion of stored value from and to String representation, which is used to serialize%0A * parameter%0A * in repository
 %0A */%0Apub
@@ -1475,173 +1475,148 @@
   * 
-Sets value of this Table parameter. Expected type of value is List%3CMap%3CString, Object%3E%3E.%0A     * null and %22%22 are also accepted. In this case empty list will be set as
+Retrieves stored value and converts it to String using %7B@link List#toString()%7D method%0A     * %0A     * @return string representation of stored
  val
@@ -1628,121 +1628,178 @@
    *
- 
+/
 %0A    
- * @param newValue new value to set%0A     */%0A    @Override%0A    public void setValue(final Object new
+public String getStringValue() %7B%0A        @SuppressWarnings(%22unchecked%22)%0A        List%3CMap%3CString, Object%3E%3E tableValue = (List%3CMap%3CString, Object%3E%3E) super.get
 Value
-) %7B
+();
 %0A   
@@ -1807,319 +1807,635 @@
     
-if (newValue == null %7C%7C %22%22.equals(newValue)) %7B%0A            super.setValue(new ArrayList%3CMap%3CString, Object%3E%3E());%0A        %7D else if (!(newValue instanceof List)) %7B%0A            throw new IllegalArgumentException(%22newValue should be of List%3CMap%3CString, Object%3E%3E type%22);%0A        %7D else %7B
+return tableValue.toString();%0A    %7D%0A%0A    /**%0A     * Converts value from string to List of Maps (Table) and delegates parent to set the value.%0A     * Expected input string is as follows: %22%5B%7Bkey1=value11, key2=value12%7D, %7Bkey1=value21, key2=value22%7D%5D%22%0A     * A Map instance in the List represents Table row. Rows are separated by %22, %22 (comma with a whitespace).%0A     * Entries in the Map are also should be separated by %22, %22.%0A     * Generally, input string should be equal to the result of a call to List.toString().%0A     * %0A     * @param newValue value to be set
 %0A     
+*/%0A
     
-   super.setValue(
+@Override%0A    public void setStringValue(final String 
 newV
@@ -2439,17 +2439,18 @@
 ewValue)
-;
+ %7B
 %0A       
@@ -2450,17 +2450,65 @@
         
-%7D
+super.setValue(ValueConverter.toTable(newValue));
 %0A    %7D%0A%0A

implement stored value conversion to string in TableElementParameter