// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getTableName(Entity entity){
//     return getTableName((Class<Entity>)entity.getClass());
// }


import com.basilgregory.onam.annotations.ManyToMany;
import com.basilgregory.onam.annotations.OneToMany;
import com.basilgregory.onam.annotations.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import static com.basilgregory.onam.android.DbUtil.getTableName;
package com.basilgregory.onam.android;




/**
 * Created by donpeter on 8/28/17.
 */

class DDLBuilder {

    static String createMappingTables(String tableName,Class fromClass,Class targetClass){
        StringBuffer ddlCreate = new StringBuffer();
        //This pattern "table [] ( " is used in #{DbUtil.extractNameOfTableFromDdl} cross check when making a change.
        ddlCreate.append("create table ").append(tableName).append(" ( ");
        ddlCreate.append(DbUtil.getMappingForeignColumnNameClass(fromClass)).append(" integer,");
        ddlCreate.append(DbUtil.getMappingForeignColumnNameClass(targetClass)).append(" integer");
        ddlCreate.append(");");
        return ddlCreate.toString();

    }


    static HashMap<String,String> createTables(List<Class> curatedClassList){

        HashMap<String,String> ddls = new HashMap<String,String>(curatedClassList.size());

        for(Class cls:curatedClassList) {
            if (cls == null || cls.getAnnotation(Table.class) == null) continue;
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getTableName(Entity entity){
//     return getTableName((Class<Entity>)entity.getClass());
// }


// Path: onam/src/main/java/com/basilgregory/onam/android/DDLBuilder.java
import com.basilgregory.onam.annotations.ManyToMany;
import com.basilgregory.onam.annotations.OneToMany;
import com.basilgregory.onam.annotations.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import static com.basilgregory.onam.android.DbUtil.getTableName;

package com.basilgregory.onam.android;




/**
 * Created by donpeter on 8/28/17.
 */

class DDLBuilder {

    static String createMappingTables(String tableName,Class fromClass,Class targetClass){
        StringBuffer ddlCreate = new StringBuffer();
        //This pattern "table [] ( " is used in #{DbUtil.extractNameOfTableFromDdl} cross check when making a change.
        ddlCreate.append("create table ").append(tableName).append(" ( ");
        ddlCreate.append(DbUtil.getMappingForeignColumnNameClass(fromClass)).append(" integer,");
        ddlCreate.append(DbUtil.getMappingForeignColumnNameClass(targetClass)).append(" integer");
        ddlCreate.append(");");
        return ddlCreate.toString();

    }


    static HashMap<String,String> createTables(List<Class> curatedClassList){

        HashMap<String,String> ddls = new HashMap<String,String>(curatedClassList.size());

        for(Class cls:curatedClassList) {
            if (cls == null || cls.getAnnotation(Table.class) == null) continue;
            ddls.put(getTableName(cls),createTable(cls));