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.planPointRepair.domain.MaintainAdjustParam;

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

    public static final String TABLENAME = "DB_MAINTAIN_ADJUST_PARAM";

    /**
     * Properties of entity MaintainAdjustParam.<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 ParentId = new Property(1, String.class, "parentId", false, "PARENT_ID");
        public final static Property Name = new Property(2, String.class, "name", false, "NAME");
        public final static Property CreateUser = new Property(3, String.class, "createUser", false, "CREATE_USER");
        public final static Property CreateUserName = new Property(4, String.class, "createUserName", false, "CREATE_USER_NAME");
        public final static Property CreateTime = new Property(5, String.class, "createTime", false, "CREATE_TIME");
        public final static Property UpdateTime = new Property(6, String.class, "updateTime", false, "UPDATE_TIME");
    }


    public MaintainAdjustParamDao(DaoConfig config) {
        super(config);
    }
    
    public MaintainAdjustParamDao(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_MAINTAIN_ADJUST_PARAM\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"PARENT_ID\" TEXT," + // 1: parentId
                "\"NAME\" TEXT," + // 2: name
                "\"CREATE_USER\" TEXT," + // 3: createUser
                "\"CREATE_USER_NAME\" TEXT," + // 4: createUserName
                "\"CREATE_TIME\" TEXT," + // 5: createTime
                "\"UPDATE_TIME\" TEXT);"); // 6: updateTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, MaintainAdjustParam entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String parentId = entity.getParentId();
        if (parentId != null) {
            stmt.bindString(2, parentId);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
 
        String createUser = entity.getCreateUser();
        if (createUser != null) {
            stmt.bindString(4, createUser);
        }
 
        String createUserName = entity.getCreateUserName();
        if (createUserName != null) {
            stmt.bindString(5, createUserName);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(6, createTime);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(7, updateTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, MaintainAdjustParam entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String parentId = entity.getParentId();
        if (parentId != null) {
            stmt.bindString(2, parentId);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
 
        String createUser = entity.getCreateUser();
        if (createUser != null) {
            stmt.bindString(4, createUser);
        }
 
        String createUserName = entity.getCreateUserName();
        if (createUserName != null) {
            stmt.bindString(5, createUserName);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(6, createTime);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(7, updateTime);
        }
    }

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

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

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

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