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

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

    public static final String TABLENAME = "BUILD_FILE_BEAN";

    /**
     * Properties of entity BuildFileBean.<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 BuilId = new Property(1, String.class, "builId", false, "BUIL_ID");
        public final static Property RepairId = new Property(2, String.class, "repairId", false, "REPAIR_ID");
        public final static Property BuildProcessId = new Property(3, String.class, "buildProcessId", false, "BUILD_PROCESS_ID");
        public final static Property RepairProcessId = new Property(4, String.class, "repairProcessId", false, "REPAIR_PROCESS_ID");
        public final static Property FileName = new Property(5, String.class, "fileName", false, "FILE_NAME");
        public final static Property FilePath = new Property(6, String.class, "FilePath", false, "FILE_PATH");
        public final static Property Status = new Property(7, int.class, "status", false, "STATUS");
    }


    public BuildFileBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildFileBeanDao(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 + "\"BUILD_FILE_BEAN\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"BUIL_ID\" TEXT," + // 1: builId
                "\"REPAIR_ID\" TEXT," + // 2: repairId
                "\"BUILD_PROCESS_ID\" TEXT," + // 3: buildProcessId
                "\"REPAIR_PROCESS_ID\" TEXT," + // 4: repairProcessId
                "\"FILE_NAME\" TEXT," + // 5: fileName
                "\"FILE_PATH\" TEXT," + // 6: FilePath
                "\"STATUS\" INTEGER NOT NULL );"); // 7: status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildFileBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String builId = entity.getBuilId();
        if (builId != null) {
            stmt.bindString(2, builId);
        }
 
        String repairId = entity.getRepairId();
        if (repairId != null) {
            stmt.bindString(3, repairId);
        }
 
        String buildProcessId = entity.getBuildProcessId();
        if (buildProcessId != null) {
            stmt.bindString(4, buildProcessId);
        }
 
        String repairProcessId = entity.getRepairProcessId();
        if (repairProcessId != null) {
            stmt.bindString(5, repairProcessId);
        }
 
        String fileName = entity.getFileName();
        if (fileName != null) {
            stmt.bindString(6, fileName);
        }
 
        String FilePath = entity.getFilePath();
        if (FilePath != null) {
            stmt.bindString(7, FilePath);
        }
        stmt.bindLong(8, entity.getStatus());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildFileBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String builId = entity.getBuilId();
        if (builId != null) {
            stmt.bindString(2, builId);
        }
 
        String repairId = entity.getRepairId();
        if (repairId != null) {
            stmt.bindString(3, repairId);
        }
 
        String buildProcessId = entity.getBuildProcessId();
        if (buildProcessId != null) {
            stmt.bindString(4, buildProcessId);
        }
 
        String repairProcessId = entity.getRepairProcessId();
        if (repairProcessId != null) {
            stmt.bindString(5, repairProcessId);
        }
 
        String fileName = entity.getFileName();
        if (fileName != null) {
            stmt.bindString(6, fileName);
        }
 
        String FilePath = entity.getFilePath();
        if (FilePath != null) {
            stmt.bindString(7, FilePath);
        }
        stmt.bindLong(8, entity.getStatus());
    }

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

    @Override
    public BuildFileBean readEntity(Cursor cursor, int offset) {
        BuildFileBean entity = new BuildFileBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // builId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // repairId
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // buildProcessId
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // repairProcessId
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // fileName
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // FilePath
            cursor.getInt(offset + 7) // status
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildFileBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setBuilId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setRepairId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setBuildProcessId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setRepairProcessId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setFileName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setFilePath(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setStatus(cursor.getInt(offset + 7));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildFileBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(BuildFileBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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