package com.tofly.data.sql.dao;

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.tofly.ghrq_route.module.buildManage.domain.BuildTypeBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DB_BUILD_TYPE".
*/
public class BuildTypeBeanDao extends AbstractDao<BuildTypeBean, String> {

    public static final String TABLENAME = "DB_BUILD_TYPE";

    /**
     * Properties of entity BuildTypeBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, String.class, "id", true, "ID");
        public final static Property Name = new Property(1, String.class, "name", false, "NAME");
        public final static Property Note = new Property(2, String.class, "note", false, "NOTE");
        public final static Property CreateUser = new Property(3, String.class, "createUser", false, "CREATE_USER");
        public final static Property CreateTime = new Property(4, String.class, "createTime", false, "CREATE_TIME");
    }


    public BuildTypeBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildTypeBeanDao(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 + "\"DB_BUILD_TYPE\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"NAME\" TEXT," + // 1: name
                "\"NOTE\" TEXT," + // 2: note
                "\"CREATE_USER\" TEXT," + // 3: createUser
                "\"CREATE_TIME\" TEXT);"); // 4: createTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildTypeBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String note = entity.getNote();
        if (note != null) {
            stmt.bindString(3, note);
        }
 
        String createUser = entity.getCreateUser();
        if (createUser != null) {
            stmt.bindString(4, createUser);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildTypeBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String note = entity.getNote();
        if (note != null) {
            stmt.bindString(3, note);
        }
 
        String createUser = entity.getCreateUser();
        if (createUser != null) {
            stmt.bindString(4, createUser);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    @Override
    public BuildTypeBean readEntity(Cursor cursor, int offset) {
        BuildTypeBean entity = new BuildTypeBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // note
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createUser
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // createTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildTypeBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setNote(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreateUser(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCreateTime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildTypeBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(BuildTypeBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(BuildTypeBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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