package com.sheep.gamegroup.greendao.download;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "SCREEN_SHOT_RECORD".
*/
public class ScreenShotRecordDao extends AbstractDao<ScreenShotRecord, Long> {

    public static final String TABLENAME = "SCREEN_SHOT_RECORD";

    /**
     * Properties of entity ScreenShotRecord.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property UserId = new Property(1, String.class, "userId", false, "user_id");
        public final static Property PackageName = new Property(2, String.class, "packageName", false, "package_name");
        public final static Property Path = new Property(3, String.class, "path", false, "path");
        public final static Property CreateTime = new Property(4, long.class, "createTime", false, "create_time");
    }


    public ScreenShotRecordDao(DaoConfig config) {
        super(config);
    }
    
    public ScreenShotRecordDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"SCREEN_SHOT_RECORD\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"user_id\" TEXT," + // 1: userId
                "\"package_name\" TEXT," + // 2: packageName
                "\"path\" TEXT," + // 3: path
                "\"create_time\" INTEGER NOT NULL );"); // 4: createTime
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SCREEN_SHOT_RECORD\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, ScreenShotRecord entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(2, userId);
        }
 
        String packageName = entity.getPackageName();
        if (packageName != null) {
            stmt.bindString(3, packageName);
        }
 
        String path = entity.getPath();
        if (path != null) {
            stmt.bindString(4, path);
        }
        stmt.bindLong(5, entity.getCreateTime());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ScreenShotRecord entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(2, userId);
        }
 
        String packageName = entity.getPackageName();
        if (packageName != null) {
            stmt.bindString(3, packageName);
        }
 
        String path = entity.getPath();
        if (path != null) {
            stmt.bindString(4, path);
        }
        stmt.bindLong(5, entity.getCreateTime());
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public ScreenShotRecord readEntity(Cursor cursor, int offset) {
        ScreenShotRecord entity = new ScreenShotRecord( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // packageName
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // path
            cursor.getLong(offset + 4) // createTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ScreenShotRecord entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setUserId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setPackageName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setPath(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCreateTime(cursor.getLong(offset + 4));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ScreenShotRecord entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ScreenShotRecord entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(ScreenShotRecord entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
