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.rushrepair.domain.RushRepairProcessBean;

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

    public static final String TABLENAME = "RUSH_REPAIR_PROCESS_BEAN";

    /**
     * Properties of entity RushRepairProcessBean.<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 Description = new Property(1, String.class, "description", false, "DESCRIPTION");
        public final static Property WorkOrderId = new Property(2, String.class, "workOrderId", false, "WORK_ORDER_ID");
        public final static Property ManageDate = new Property(3, String.class, "manageDate", false, "MANAGE_DATE");
        public final static Property X = new Property(4, double.class, "x", false, "X");
        public final static Property Y = new Property(5, double.class, "y", false, "Y");
        public final static Property Submit_state = new Property(6, String.class, "submit_state", false, "SUBMIT_STATE");
    }


    public RushRepairProcessBeanDao(DaoConfig config) {
        super(config);
    }
    
    public RushRepairProcessBeanDao(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 + "\"RUSH_REPAIR_PROCESS_BEAN\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"DESCRIPTION\" TEXT," + // 1: description
                "\"WORK_ORDER_ID\" TEXT," + // 2: workOrderId
                "\"MANAGE_DATE\" TEXT," + // 3: manageDate
                "\"X\" REAL NOT NULL ," + // 4: x
                "\"Y\" REAL NOT NULL ," + // 5: y
                "\"SUBMIT_STATE\" TEXT);"); // 6: submit_state
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, RushRepairProcessBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(2, description);
        }
 
        String workOrderId = entity.getWorkOrderId();
        if (workOrderId != null) {
            stmt.bindString(3, workOrderId);
        }
 
        String manageDate = entity.getManageDate();
        if (manageDate != null) {
            stmt.bindString(4, manageDate);
        }
        stmt.bindDouble(5, entity.getX());
        stmt.bindDouble(6, entity.getY());
 
        String submit_state = entity.getSubmit_state();
        if (submit_state != null) {
            stmt.bindString(7, submit_state);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, RushRepairProcessBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(2, description);
        }
 
        String workOrderId = entity.getWorkOrderId();
        if (workOrderId != null) {
            stmt.bindString(3, workOrderId);
        }
 
        String manageDate = entity.getManageDate();
        if (manageDate != null) {
            stmt.bindString(4, manageDate);
        }
        stmt.bindDouble(5, entity.getX());
        stmt.bindDouble(6, entity.getY());
 
        String submit_state = entity.getSubmit_state();
        if (submit_state != null) {
            stmt.bindString(7, submit_state);
        }
    }

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

    @Override
    public RushRepairProcessBean readEntity(Cursor cursor, int offset) {
        RushRepairProcessBean entity = new RushRepairProcessBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // description
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // workOrderId
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // manageDate
            cursor.getDouble(offset + 4), // x
            cursor.getDouble(offset + 5), // y
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // submit_state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, RushRepairProcessBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setDescription(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setWorkOrderId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setManageDate(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setX(cursor.getDouble(offset + 4));
        entity.setY(cursor.getDouble(offset + 5));
        entity.setSubmit_state(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
     }
    
    @Override
    protected final String updateKeyAfterInsert(RushRepairProcessBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(RushRepairProcessBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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