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.systemConfig.domain.ServerSysConfigBean;

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

    public static final String TABLENAME = "DB_SERVER_SYS_CONFIG";

    /**
     * Properties of entity ServerSysConfigBean.<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 Key = new Property(1, String.class, "key", false, "KEY");
        public final static Property Value = new Property(2, String.class, "value", false, "VALUE");
        public final static Property Create_userid = new Property(3, String.class, "create_userid", false, "CREATE_USERID");
        public final static Property Create_time = new Property(4, String.class, "create_time", false, "CREATE_TIME");
        public final static Property Notes = new Property(5, String.class, "notes", false, "NOTES");
        public final static Property Start_date = new Property(6, String.class, "start_date", false, "START_DATE");
        public final static Property End_date = new Property(7, String.class, "end_date", false, "END_DATE");
        public final static Property Forbid_delete = new Property(8, int.class, "forbid_delete", false, "FORBID_DELETE");
        public final static Property Icon = new Property(9, String.class, "icon", false, "ICON");
    }


    public ServerSysConfigBeanDao(DaoConfig config) {
        super(config);
    }
    
    public ServerSysConfigBeanDao(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_SERVER_SYS_CONFIG\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"KEY\" TEXT," + // 1: key
                "\"VALUE\" TEXT," + // 2: value
                "\"CREATE_USERID\" TEXT," + // 3: create_userid
                "\"CREATE_TIME\" TEXT," + // 4: create_time
                "\"NOTES\" TEXT," + // 5: notes
                "\"START_DATE\" TEXT," + // 6: start_date
                "\"END_DATE\" TEXT," + // 7: end_date
                "\"FORBID_DELETE\" INTEGER NOT NULL ," + // 8: forbid_delete
                "\"ICON\" TEXT);"); // 9: icon
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, ServerSysConfigBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String key = entity.getKey();
        if (key != null) {
            stmt.bindString(2, key);
        }
 
        String value = entity.getValue();
        if (value != null) {
            stmt.bindString(3, value);
        }
 
        String create_userid = entity.getCreate_userid();
        if (create_userid != null) {
            stmt.bindString(4, create_userid);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(5, create_time);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(6, notes);
        }
 
        String start_date = entity.getStart_date();
        if (start_date != null) {
            stmt.bindString(7, start_date);
        }
 
        String end_date = entity.getEnd_date();
        if (end_date != null) {
            stmt.bindString(8, end_date);
        }
        stmt.bindLong(9, entity.getForbid_delete());
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(10, icon);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ServerSysConfigBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String key = entity.getKey();
        if (key != null) {
            stmt.bindString(2, key);
        }
 
        String value = entity.getValue();
        if (value != null) {
            stmt.bindString(3, value);
        }
 
        String create_userid = entity.getCreate_userid();
        if (create_userid != null) {
            stmt.bindString(4, create_userid);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(5, create_time);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(6, notes);
        }
 
        String start_date = entity.getStart_date();
        if (start_date != null) {
            stmt.bindString(7, start_date);
        }
 
        String end_date = entity.getEnd_date();
        if (end_date != null) {
            stmt.bindString(8, end_date);
        }
        stmt.bindLong(9, entity.getForbid_delete());
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(10, icon);
        }
    }

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

    @Override
    public ServerSysConfigBean readEntity(Cursor cursor, int offset) {
        ServerSysConfigBean entity = new ServerSysConfigBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // key
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // value
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // create_userid
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // create_time
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // notes
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // start_date
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // end_date
            cursor.getInt(offset + 8), // forbid_delete
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // icon
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ServerSysConfigBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setKey(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setValue(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreate_userid(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCreate_time(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setNotes(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setStart_date(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setEnd_date(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setForbid_delete(cursor.getInt(offset + 8));
        entity.setIcon(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
     }
    
    @Override
    protected final String updateKeyAfterInsert(ServerSysConfigBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(ServerSysConfigBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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