// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/Binder.java
// public abstract class Binder {
//     public static final String PACKAGE = "com.wellsql.generated";
//     public static final String LOOKUP_CLASS = "GeneratedLookup";
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/Identifiable.java
// public interface Identifiable {
//     void setId(int id);
//     int getId();
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/TableClass.java
// public interface TableClass {
//     String createStatement();
//     String getTableName();
//     boolean shouldAutoincrementId();
//     Class<?> getModelClass();
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/TableLookup.java
// public interface TableLookup {
//     <T>Mapper<T> getMapper(Class<T> token);
//     TableClass getTable(Class<?> token);
// 
//     Set<Class<?>> getMapperTokens();
//     Set<Class<?>> getTableTokens();
// }
// 
// Path: wellsql/src/main/java/com/yarolegovich/wellsql/mapper/MapperAdapter.java
// public class MapperAdapter<T> implements SQLiteMapper<T> {
// 
//     private Mapper<T> mMapper;
// 
//     public MapperAdapter(Mapper<T> mapper) {
//         mMapper = mapper;
//     }
// 
//     @Override
//     public ContentValues toCv(T item) {
//         ContentValues cv = new ContentValues();
//         Map<String, Object> vals = mMapper.toContentValues(item);
//         for (String key : vals.keySet()) {
//             Object obj = vals.get(key);
//             if (obj instanceof String) {
//                 cv.put(key, (String) obj);
//             } else if (obj instanceof Integer) {
//                 cv.put(key, (Integer) obj);
//             } else if (obj instanceof Double) {
//                 cv.put(key, (Double) obj);
//             } else if (obj instanceof byte[]) {
//                 cv.put(key, (byte[]) obj);
//             } else if (obj instanceof Boolean) {
//                 cv.put(key, (Boolean) obj);
//             } else if (obj instanceof Byte) {
//                 cv.put(key, (Byte) obj);
//             } else if (obj instanceof Float) {
//                 cv.put(key, (Float) obj);
//             } else if (obj instanceof Long) {
//                 cv.put(key, (Long) obj);
//             } else if (obj instanceof Short) {
//                 cv.put(key, (Short) obj);
//             } else if (obj == null) {
//                 cv.putNull(key);
//             } else {
//                 throw new WellException("Type " + obj.getClass().getSimpleName() + " unsupported, failed to create ContentValues. " +
//                         "Write custom converter for " + item.getClass().getSimpleName() + " and register " +
//                         "it in WellConfig.");
//             }
//         }
//         return cv;
//     }
// 
//     @Override
//     public T convert(Cursor item) {
//         Map<String, Object> map = new HashMap<>();
//         for (String column : item.getColumnNames()) {
//             int columnIndex = item.getColumnIndex(column);
//             switch (item.getType(columnIndex)) {
//                 case Cursor.FIELD_TYPE_INTEGER:
//                     map.put(column, item.getLong(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_STRING:
//                     map.put(column, item.getString(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_FLOAT:
//                     map.put(column, item.getFloat(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_BLOB:
//                     map.put(column, item.getBlob(columnIndex));
//                     break;
//             }
//         }
//         return mMapper.convert(map);
//     }
// }
// 
// Path: wellsql/src/main/java/com/yarolegovich/wellsql/mapper/SQLiteMapper.java
// public interface SQLiteMapper<T> extends InsertMapper<T>, SelectMapper<T> {}


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import com.yarolegovich.wellsql.core.Binder;
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.TableClass;
import com.yarolegovich.wellsql.core.TableLookup;
import com.yarolegovich.wellsql.mapper.MapperAdapter;
import com.yarolegovich.wellsql.mapper.SQLiteMapper;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
package com.yarolegovich.wellsql;




/**
 * Created by yarolegovich on 26.11.2015.
 */
@SuppressWarnings("unchecked")
public abstract class DefaultWellConfig implements WellConfig,
        WellConfig.OnUpgradeListener, WellConfig.OnCreateListener, WellConfig.OnDowngradeListener {

    private Context mContext;
    private TableLookup mGeneratedLookup;
    private Map<Class<?>, SQLiteMapper<?>> mMappers;

    public DefaultWellConfig(Context context) {
        mContext = context.getApplicationContext();
        mMappers = new HashMap<>();
        try {
            Class<? extends TableLookup> clazz = (Class<? extends TableLookup>)
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/Binder.java
// public abstract class Binder {
//     public static final String PACKAGE = "com.wellsql.generated";
//     public static final String LOOKUP_CLASS = "GeneratedLookup";
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/Identifiable.java
// public interface Identifiable {
//     void setId(int id);
//     int getId();
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/TableClass.java
// public interface TableClass {
//     String createStatement();
//     String getTableName();
//     boolean shouldAutoincrementId();
//     Class<?> getModelClass();
// }
// 
// Path: well-annotations/src/main/java/com/yarolegovich/wellsql/core/TableLookup.java
// public interface TableLookup {
//     <T>Mapper<T> getMapper(Class<T> token);
//     TableClass getTable(Class<?> token);
// 
//     Set<Class<?>> getMapperTokens();
//     Set<Class<?>> getTableTokens();
// }
// 
// Path: wellsql/src/main/java/com/yarolegovich/wellsql/mapper/MapperAdapter.java
// public class MapperAdapter<T> implements SQLiteMapper<T> {
// 
//     private Mapper<T> mMapper;
// 
//     public MapperAdapter(Mapper<T> mapper) {
//         mMapper = mapper;
//     }
// 
//     @Override
//     public ContentValues toCv(T item) {
//         ContentValues cv = new ContentValues();
//         Map<String, Object> vals = mMapper.toContentValues(item);
//         for (String key : vals.keySet()) {
//             Object obj = vals.get(key);
//             if (obj instanceof String) {
//                 cv.put(key, (String) obj);
//             } else if (obj instanceof Integer) {
//                 cv.put(key, (Integer) obj);
//             } else if (obj instanceof Double) {
//                 cv.put(key, (Double) obj);
//             } else if (obj instanceof byte[]) {
//                 cv.put(key, (byte[]) obj);
//             } else if (obj instanceof Boolean) {
//                 cv.put(key, (Boolean) obj);
//             } else if (obj instanceof Byte) {
//                 cv.put(key, (Byte) obj);
//             } else if (obj instanceof Float) {
//                 cv.put(key, (Float) obj);
//             } else if (obj instanceof Long) {
//                 cv.put(key, (Long) obj);
//             } else if (obj instanceof Short) {
//                 cv.put(key, (Short) obj);
//             } else if (obj == null) {
//                 cv.putNull(key);
//             } else {
//                 throw new WellException("Type " + obj.getClass().getSimpleName() + " unsupported, failed to create ContentValues. " +
//                         "Write custom converter for " + item.getClass().getSimpleName() + " and register " +
//                         "it in WellConfig.");
//             }
//         }
//         return cv;
//     }
// 
//     @Override
//     public T convert(Cursor item) {
//         Map<String, Object> map = new HashMap<>();
//         for (String column : item.getColumnNames()) {
//             int columnIndex = item.getColumnIndex(column);
//             switch (item.getType(columnIndex)) {
//                 case Cursor.FIELD_TYPE_INTEGER:
//                     map.put(column, item.getLong(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_STRING:
//                     map.put(column, item.getString(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_FLOAT:
//                     map.put(column, item.getFloat(columnIndex));
//                     break;
//                 case Cursor.FIELD_TYPE_BLOB:
//                     map.put(column, item.getBlob(columnIndex));
//                     break;
//             }
//         }
//         return mMapper.convert(map);
//     }
// }
// 
// Path: wellsql/src/main/java/com/yarolegovich/wellsql/mapper/SQLiteMapper.java
// public interface SQLiteMapper<T> extends InsertMapper<T>, SelectMapper<T> {}


// Path: wellsql/src/main/java/com/yarolegovich/wellsql/DefaultWellConfig.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import com.yarolegovich.wellsql.core.Binder;
import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.TableClass;
import com.yarolegovich.wellsql.core.TableLookup;
import com.yarolegovich.wellsql.mapper.MapperAdapter;
import com.yarolegovich.wellsql.mapper.SQLiteMapper;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

package com.yarolegovich.wellsql;




/**
 * Created by yarolegovich on 26.11.2015.
 */
@SuppressWarnings("unchecked")
public abstract class DefaultWellConfig implements WellConfig,
        WellConfig.OnUpgradeListener, WellConfig.OnCreateListener, WellConfig.OnDowngradeListener {

    private Context mContext;
    private TableLookup mGeneratedLookup;
    private Map<Class<?>, SQLiteMapper<?>> mMappers;

    public DefaultWellConfig(Context context) {
        mContext = context.getApplicationContext();
        mMappers = new HashMap<>();
        try {
            Class<? extends TableLookup> clazz = (Class<? extends TableLookup>)
                    Class.forName(Binder.PACKAGE + "." + Binder.LOOKUP_CLASS);