package org.talend.dataprep.helper.api;

import java.util.Arrays;

import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonValue;

/**
 * {@link Enum} representation of {@link Action} parameters types.
 */
public enum ActionParamEnum {
    FROM_PATTERN_MODE("fromPatternMode", "from_pattern_mode"),
    NEW_PATTERN("newPattern", "new_pattern"),
    SCOPE("scope", "scope"),
    COLUMN_NAME("columnName", "column_name"),
    COLUMN_ID("columnId", "column_id"),
    ROW_ID("rowId", "row_id"),
    LIMIT("limit", "limit"),
    SEPARATOR("separator", "separator"),
    MANUAL_SEPARATOR_STRING("manualSeparatorString", "manual_separator_string"),
    MANUAL_SEPARATOR_REGEX("manualSeparatorRegex", "manual_separator_regex"),
    FILTER("filter", "filter"),
    REGION_CODE("regionCode","region_code"),
    MODE("mode","mode"),
    FORMAT_TYPE("formatType","format_type"),
    OPERATOR("operator","operator"),
    OPERAND("operand","operand"),
    NEW_DOMAIN_ID("new_domain_id","new_domain_id"),
    CREATE_NEW_COLUMN("createNewColumn","create_new_column");

    private String name;

    private String jsonName;

    ActionParamEnum(String pName, String pJsonName) {
        name = pName;
        jsonName = pJsonName;
    }

    /**
     * Get a corresponding {@link ActionParamEnum} from a {@link String}.
     *
     * @param pName the {@link ActionParamEnum#name}.
     * @return the corresponding {@link ActionParamEnum} or <code>null</code> if there isn't.
     */
    @Nullable
    public static ActionParamEnum getActionParamEnum(@NotNull String pName) {
        return Arrays.stream(ActionParamEnum.values()) //
                .filter(e -> e.name.equalsIgnoreCase(pName)) //
                .findFirst() //
                .orElse(null);
    }

    public String getName() {
        return name;
    }

    @JsonValue
    public String getJsonName() {
        return jsonName;
    }
}

@@ -59,17 +59,16 @@
 Arrays;%0A
-%0A
 import j
@@ -1017,43 +1017,237 @@
 AIN_
-ID(%22new_domain_id%22,%22new_domain_id%22)
+LABEL,%0A    NEW_DOMAIN_FREQUENCY,%0A    NEW_DOMAIN_ID,%0A    SELECTED_COLUMN,%0A    MODE_NEW_COLUMN,%0A    CREATE_NEW_COLUMN_NAME,%0A    ORIGINAL_VALUE,%0A    NEW_VALUE,%0A    PADDING_CHARACTER,%0A    CUSTOM_PADDING_CHARACTER,%0A    MATCH_THRESHOLD
 ,%0A  
@@ -1435,24 +1435,24 @@
 me = pName;%0A
-
         json
@@ -1472,24 +1472,102 @@
 ame;%0A    %7D%0A%0A
+    ActionParamEnum()%7B%0A        name = jsonName = name().toLowerCase();%0A    %7D%0A%0A
     /**%0A    

fix integration tests