package com.oo.eye.gen;

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;

import com.oo.eye.bean.EyeHistroyBean;

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

    public static final String TABLENAME = "EYE_HISTROY_BEAN";

    /**
     * Properties of entity EyeHistroyBean.<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 Left_eye = new Property(1, double.class, "left_eye", false, "LEFT_EYE");
        public final static Property Right_eye = new Property(2, double.class, "right_eye", false, "RIGHT_EYE");
        public final static Property Left_line = new Property(3, int.class, "left_line", false, "LEFT_LINE");
        public final static Property Right_line = new Property(4, int.class, "right_line", false, "RIGHT_LINE");
        public final static Property Created_time = new Property(5, long.class, "created_time", false, "CREATED_TIME");
        public final static Property Type = new Property(6, int.class, "type", false, "TYPE");
    }


    public EyeHistroyBeanDao(DaoConfig config) {
        super(config);
    }
    
    public EyeHistroyBeanDao(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 + "\"EYE_HISTROY_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"LEFT_EYE\" REAL NOT NULL ," + // 1: left_eye
                "\"RIGHT_EYE\" REAL NOT NULL ," + // 2: right_eye
                "\"LEFT_LINE\" INTEGER NOT NULL ," + // 3: left_line
                "\"RIGHT_LINE\" INTEGER NOT NULL ," + // 4: right_line
                "\"CREATED_TIME\" INTEGER NOT NULL UNIQUE ," + // 5: created_time
                "\"TYPE\" INTEGER NOT NULL );"); // 6: type
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, EyeHistroyBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindDouble(2, entity.getLeft_eye());
        stmt.bindDouble(3, entity.getRight_eye());
        stmt.bindLong(4, entity.getLeft_line());
        stmt.bindLong(5, entity.getRight_line());
        stmt.bindLong(6, entity.getCreated_time());
        stmt.bindLong(7, entity.getType());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, EyeHistroyBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindDouble(2, entity.getLeft_eye());
        stmt.bindDouble(3, entity.getRight_eye());
        stmt.bindLong(4, entity.getLeft_line());
        stmt.bindLong(5, entity.getRight_line());
        stmt.bindLong(6, entity.getCreated_time());
        stmt.bindLong(7, entity.getType());
    }

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

    @Override
    public EyeHistroyBean readEntity(Cursor cursor, int offset) {
        EyeHistroyBean entity = new EyeHistroyBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.getDouble(offset + 1), // left_eye
            cursor.getDouble(offset + 2), // right_eye
            cursor.getInt(offset + 3), // left_line
            cursor.getInt(offset + 4), // right_line
            cursor.getLong(offset + 5), // created_time
            cursor.getInt(offset + 6) // type
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, EyeHistroyBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setLeft_eye(cursor.getDouble(offset + 1));
        entity.setRight_eye(cursor.getDouble(offset + 2));
        entity.setLeft_line(cursor.getInt(offset + 3));
        entity.setRight_line(cursor.getInt(offset + 4));
        entity.setCreated_time(cursor.getLong(offset + 5));
        entity.setType(cursor.getInt(offset + 6));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(EyeHistroyBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(EyeHistroyBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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