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.BuildProjectTypeBean;

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

    public static final String TABLENAME = "DB_BUILD_PROJECT_TYPE";

    /**
     * Properties of entity BuildProjectTypeBean.<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 Notes = new Property(2, String.class, "notes", false, "NOTES");
        public final static Property Create_time = new Property(3, String.class, "create_time", false, "CREATE_TIME");
    }


    public BuildProjectTypeBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildProjectTypeBeanDao(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_PROJECT_TYPE\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"NAME\" TEXT," + // 1: name
                "\"NOTES\" TEXT," + // 2: notes
                "\"CREATE_TIME\" TEXT);"); // 3: create_time
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildProjectTypeBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(3, notes);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(4, create_time);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildProjectTypeBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(3, notes);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(4, create_time);
        }
    }

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

    @Override
    public BuildProjectTypeBean readEntity(Cursor cursor, int offset) {
        BuildProjectTypeBean entity = new BuildProjectTypeBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // notes
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // create_time
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildProjectTypeBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setNotes(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreate_time(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildProjectTypeBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(BuildProjectTypeBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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