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.troubleType.domain.PipeTypeBean;

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

    public static final String TABLENAME = "DB_PIPE_TYPE";

    /**
     * Properties of entity PipeTypeBean.<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 CreateUserid = new Property(3, int.class, "createUserid", false, "CREATE_USERID");
        public final static Property CreateTime = new Property(4, String.class, "createTime", false, "CREATE_TIME");
        public final static Property Version = new Property(5, String.class, "version", false, "VERSION");
        public final static Property Delstate = new Property(6, int.class, "delstate", false, "DELSTATE");
        public final static Property De1Flag = new Property(7, String.class, "de1Flag", false, "DE1_FLAG");
    }


    public PipeTypeBeanDao(DaoConfig config) {
        super(config);
    }
    
    public PipeTypeBeanDao(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_PIPE_TYPE\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"NAME\" TEXT," + // 1: name
                "\"NOTES\" TEXT," + // 2: notes
                "\"CREATE_USERID\" INTEGER NOT NULL ," + // 3: createUserid
                "\"CREATE_TIME\" TEXT," + // 4: createTime
                "\"VERSION\" TEXT," + // 5: version
                "\"DELSTATE\" INTEGER NOT NULL ," + // 6: delstate
                "\"DE1_FLAG\" TEXT);"); // 7: de1Flag
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, PipeTypeBean 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);
        }
        stmt.bindLong(4, entity.getCreateUserid());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
 
        String version = entity.getVersion();
        if (version != null) {
            stmt.bindString(6, version);
        }
        stmt.bindLong(7, entity.getDelstate());
 
        String de1Flag = entity.getDe1Flag();
        if (de1Flag != null) {
            stmt.bindString(8, de1Flag);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PipeTypeBean 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);
        }
        stmt.bindLong(4, entity.getCreateUserid());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
 
        String version = entity.getVersion();
        if (version != null) {
            stmt.bindString(6, version);
        }
        stmt.bindLong(7, entity.getDelstate());
 
        String de1Flag = entity.getDe1Flag();
        if (de1Flag != null) {
            stmt.bindString(8, de1Flag);
        }
    }

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

    @Override
    public PipeTypeBean readEntity(Cursor cursor, int offset) {
        PipeTypeBean entity = new PipeTypeBean( //
            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.getInt(offset + 3), // createUserid
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // createTime
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // version
            cursor.getInt(offset + 6), // delstate
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // de1Flag
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PipeTypeBean 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.setCreateUserid(cursor.getInt(offset + 3));
        entity.setCreateTime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setVersion(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setDelstate(cursor.getInt(offset + 6));
        entity.setDe1Flag(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
     }
    
    @Override
    protected final String updateKeyAfterInsert(PipeTypeBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(PipeTypeBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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