// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getColumnName(Field field){
//     return getColumnName(getMethod("get", field));
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getMappingForeignColumnNameClass(Class aClass){
//     return aClass.getSimpleName().toLowerCase()+"_id";
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static  Method getMethod (String prefix, Field field) {
//     if (field == null) return null;
//     String name = prefix + field.getName();
//     try {
//         switch (prefix.toLowerCase()) {
//             case "set":
//                 return findSetterMethod(name,field.getDeclaringClass(), field.getType());
//             case "get" :
//                 return findGetterMethod(name,field.getDeclaringClass());
//         }
//     } catch (Exception e) {
//         e.printStackTrace();
//     }
//     L.w("No "+prefix +" method found for "+field.getName());
// 
//     return null;
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/Entity.java
// public static <E extends Entity> E find(Class entityClass,long id){
//     return (E) DBExecutor.getInstance().findById(entityClass,id);
// 
// }


import android.database.Cursor;
import com.basilgregory.onam.annotations.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import static com.basilgregory.onam.android.DbUtil.getColumnName;
import static com.basilgregory.onam.android.DbUtil.getMappingForeignColumnNameClass;
import static com.basilgregory.onam.android.DbUtil.getMethod;
import static com.basilgregory.onam.android.Entity.find;
package com.basilgregory.onam.android;





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

class EntityBuilder {

    static List<Entity> getEntityFromMappingTable(Cursor cursor, Class collectionType){
        if (cursor == null || cursor.getCount() < 1) return null;
        cursor.moveToFirst();
        List<Entity> entities = new ArrayList<>();
        do{
            long foreignKey = cursor.getLong
                    (cursor.getColumnIndex(
                            getMappingForeignColumnNameClass(collectionType)));
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getColumnName(Field field){
//     return getColumnName(getMethod("get", field));
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static String getMappingForeignColumnNameClass(Class aClass){
//     return aClass.getSimpleName().toLowerCase()+"_id";
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/DbUtil.java
// static  Method getMethod (String prefix, Field field) {
//     if (field == null) return null;
//     String name = prefix + field.getName();
//     try {
//         switch (prefix.toLowerCase()) {
//             case "set":
//                 return findSetterMethod(name,field.getDeclaringClass(), field.getType());
//             case "get" :
//                 return findGetterMethod(name,field.getDeclaringClass());
//         }
//     } catch (Exception e) {
//         e.printStackTrace();
//     }
//     L.w("No "+prefix +" method found for "+field.getName());
// 
//     return null;
// }
// 
// Path: onam/src/main/java/com/basilgregory/onam/android/Entity.java
// public static <E extends Entity> E find(Class entityClass,long id){
//     return (E) DBExecutor.getInstance().findById(entityClass,id);
// 
// }


// Path: onam/src/main/java/com/basilgregory/onam/android/EntityBuilder.java
import android.database.Cursor;
import com.basilgregory.onam.annotations.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import static com.basilgregory.onam.android.DbUtil.getColumnName;
import static com.basilgregory.onam.android.DbUtil.getMappingForeignColumnNameClass;
import static com.basilgregory.onam.android.DbUtil.getMethod;
import static com.basilgregory.onam.android.Entity.find;

package com.basilgregory.onam.android;





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

class EntityBuilder {

    static List<Entity> getEntityFromMappingTable(Cursor cursor, Class collectionType){
        if (cursor == null || cursor.getCount() < 1) return null;
        cursor.moveToFirst();
        List<Entity> entities = new ArrayList<>();
        do{
            long foreignKey = cursor.getLong
                    (cursor.getColumnIndex(
                            getMappingForeignColumnNameClass(collectionType)));
            Entity queriedEntity = find(collectionType,foreignKey);