com.github.gkutiel.store.Java2Sql Maven / Gradle / Ivy
package com.github.gkutiel.store;
import java.util.HashMap;
import java.util.Map;
public class Java2Sql {
private static final Map, String> JAVA_2_SQL = new HashMap<>();
static {
JAVA_2_SQL.put(boolean.class, "BOOLEAN");
JAVA_2_SQL.put(Boolean.class, "BOOLEAN");
JAVA_2_SQL.put(int.class, "INT");
JAVA_2_SQL.put(Integer.class, "INT");
JAVA_2_SQL.put(long.class, "BIGINT");
JAVA_2_SQL.put(Long.class, "BIGINT");
JAVA_2_SQL.put(double.class, "DOUBLE");
JAVA_2_SQL.put(Double.class, "DOUBLE");
JAVA_2_SQL.put(String.class, "VARCHAR");
}
public static String toSql(final Class> c) {
if (!JAVA_2_SQL.containsKey(c)) throw new IllegalArgumentException(c + " is not supported");
return JAVA_2_SQL.get(c);
}
}