package com.stratio.connector.inmemory.datastore.datatypes;

import com.stratio.crossdata.common.metadata.DataType;
import org.apache.log4j.Logger;

import com.stratio.crossdata.common.exceptions.ExecutionException;

public abstract class AbstractInMemoryDataType {

    /**
     * Class logger.
     */
    protected static final Logger LOG = Logger.getLogger(AbstractInMemoryDataType.class);

    public abstract Class<?> getClazz();

    public abstract void setClazz(Class<?> clazz);

    public abstract void setParameters(Object... parameters);

    public abstract Object convertStringToInMemoryDataType(String input) throws ExecutionException;

    public abstract String convertInMemoryDataTypeToString(Object input);

    public static AbstractInMemoryDataType castToNativeDataType(String dataType)  throws ExecutionException{
        AbstractInMemoryDataType nativeDataType = null;
        if(dataType != null){
            if(dataType.equals("Date")){
                nativeDataType = new Date();
            }else{
                try {
                    DataType.valueOf(dataType);
                }catch (IllegalArgumentException e){
                    throw new ExecutionException("You have an error in your SQL syntax, the type '" + dataType + "' is not supported");
                }
            }
        }
        return nativeDataType;
    }

}

@@ -210,16 +210,65 @@
 ption;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 public a
@@ -433,24 +433,465 @@
 pe.class);%0A%0A
+    private static final Set%3CString%3E SUPPORTED_TYPES = new HashSet();%0A    static%7B%0A        SUPPORTED_TYPES.add(Boolean.class.getSimpleName());%0A        SUPPORTED_TYPES.add(String.class.getSimpleName());%0A        SUPPORTED_TYPES.add(Float.class.getSimpleName());%0A        SUPPORTED_TYPES.add(Integer.class.getSimpleName());%0A        SUPPORTED_TYPES.add(Double.class.getSimpleName());%0A        SUPPORTED_TYPES.add(Long.class.getSimpleName());%0A    %7D%0A
     public a
@@ -1513,137 +1513,52 @@
 else
-%7B%0A                try %7B%0A                    DataType.valueOf(dataType);%0A                %7Dcatch (IllegalArgumentException e)%7B%0A    
+ if (!SUPPORTED_TYPES.contains(dataType)) %7B%0A
     
@@ -1689,26 +1689,8 @@
 %22);%0A
-                %7D%0A
     

Fix Crossdata-628, AbstractInMemoryDataType validation