// Path: src/main/java/com/itranswarp/warpdb/util/NameUtils.java
// public class NameUtils {
// 
// 	/**
// 	 * to camel case name. e.g. "HelloWorld" to "helloWorld.
// 	 * 
// 	 * @param name
// 	 *            Name starts with upper case.
// 	 * @return Camel case name.
// 	 */
// 	public static String toCamelCaseName(String name) {
// 		return Character.toLowerCase(name.charAt(0)) + name.substring(1);
// 	}
// 
// 	/**
// 	 * To underscore name. e.g. "HelloWorld" to "hello_world".
// 	 * 
// 	 * @param name
// 	 *            Name without underscore.
// 	 * @return Underscore name.
// 	 */
// 	public static String toUnderscoreName(String name) {
// 		StringBuilder sb = new StringBuilder(name.length() + 5);
// 		for (int i = 0; i < name.length(); i++) {
// 			char ch = name.charAt(i);
// 			if (Character.isUpperCase(ch)) {
// 				if (i > 0) {
// 					sb.append('_');
// 				}
// 				sb.append(Character.toLowerCase(ch));
// 			} else {
// 				sb.append(ch);
// 			}
// 		}
// 		return sb.toString();
// 	}
// }


import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.itranswarp.warpdb.util.NameUtils;
		return list;
	}

	void findMethodsIncludeHierarchy(Class<?> clazz, List<Method> methods) {
		Method[] ms = clazz.getDeclaredMethods();
		for (Method m : ms) {
			methods.add(m);
		}
		if (clazz.getSuperclass() != Object.class) {
			findMethodsIncludeHierarchy(clazz.getSuperclass(), methods);
		}
	}

	String numOfQuestions(int n) {
		String[] qs = new String[n];
		return String.join(", ", Arrays.stream(qs).map((s) -> {
			return "?";
		}).toArray(String[]::new));
	}

	String getTableName(Class<?> clazz) {
		Table table = clazz.getAnnotation(Table.class);
		if (table != null) {
			String schema = table.schema();
			String tableName = table.name();
			if (tableName.isEmpty()) {
				tableName = NameUtils.toCamelCaseName(clazz.getSimpleName());
			}
			return schema.isEmpty() ? tableName : schema + "." + tableName;
		}
// Path: src/main/java/com/itranswarp/warpdb/util/NameUtils.java
// public class NameUtils {
// 
// 	/**
// 	 * to camel case name. e.g. "HelloWorld" to "helloWorld.
// 	 * 
// 	 * @param name
// 	 *            Name starts with upper case.
// 	 * @return Camel case name.
// 	 */
// 	public static String toCamelCaseName(String name) {
// 		return Character.toLowerCase(name.charAt(0)) + name.substring(1);
// 	}
// 
// 	/**
// 	 * To underscore name. e.g. "HelloWorld" to "hello_world".
// 	 * 
// 	 * @param name
// 	 *            Name without underscore.
// 	 * @return Underscore name.
// 	 */
// 	public static String toUnderscoreName(String name) {
// 		StringBuilder sb = new StringBuilder(name.length() + 5);
// 		for (int i = 0; i < name.length(); i++) {
// 			char ch = name.charAt(i);
// 			if (Character.isUpperCase(ch)) {
// 				if (i > 0) {
// 					sb.append('_');
// 				}
// 				sb.append(Character.toLowerCase(ch));
// 			} else {
// 				sb.append(ch);
// 			}
// 		}
// 		return sb.toString();
// 	}
// }


// Path: src/main/java/com/itranswarp/warpdb/Mapper.java
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.itranswarp.warpdb.util.NameUtils;

		return list;
	}

	void findMethodsIncludeHierarchy(Class<?> clazz, List<Method> methods) {
		Method[] ms = clazz.getDeclaredMethods();
		for (Method m : ms) {
			methods.add(m);
		}
		if (clazz.getSuperclass() != Object.class) {
			findMethodsIncludeHierarchy(clazz.getSuperclass(), methods);
		}
	}

	String numOfQuestions(int n) {
		String[] qs = new String[n];
		return String.join(", ", Arrays.stream(qs).map((s) -> {
			return "?";
		}).toArray(String[]::new));
	}

	String getTableName(Class<?> clazz) {
		Table table = clazz.getAnnotation(Table.class);
		if (table != null) {
			String schema = table.schema();
			String tableName = table.name();
			if (tableName.isEmpty()) {
				tableName = NameUtils.toCamelCaseName(clazz.getSimpleName());
			}
			return schema.isEmpty() ? tableName : schema + "." + tableName;
		}
		return NameUtils.toCamelCaseName(clazz.getSimpleName());