package com.kfzs.duanduan.datashare.provider.appdownload;

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.kfzs.duanduan.data.graph.provider.channel.DaoSession;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "APPDOWNLOAD_BEAN".
*/
public class AppdownloadBeanDao extends AbstractDao<AppdownloadBean, Long> {

    public static final String TABLENAME = "APPDOWNLOAD_BEAN";

    /**
     * Properties of entity AppdownloadBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property MId = new Property(0, Long.class, "mId", true, "_id");
        public final static Property Name = new Property(1, String.class, "name", false, "NAME");
        public final static Property Icon = new Property(2, String.class, "icon", false, "ICON");
        public final static Property Url = new Property(3, String.class, "url", false, "URL");
        public final static Property PkgName = new Property(4, String.class, "pkgName", false, "PKG_NAME");
        public final static Property InterfaceName = new Property(5, String.class, "interfaceName", false, "INTERFACE_NAME");
        public final static Property Staus = new Property(6, int.class, "staus", false, "STAUS");
    }


    public AppdownloadBeanDao(DaoConfig config) {
        super(config);
    }
    
    public AppdownloadBeanDao(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 + "\"APPDOWNLOAD_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: mId
                "\"NAME\" TEXT," + // 1: name
                "\"ICON\" TEXT," + // 2: icon
                "\"URL\" TEXT," + // 3: url
                "\"PKG_NAME\" TEXT NOT NULL UNIQUE ," + // 4: pkgName
                "\"INTERFACE_NAME\" TEXT," + // 5: interfaceName
                "\"STAUS\" INTEGER NOT NULL );"); // 6: staus
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, AppdownloadBean entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(3, icon);
        }
 
        String url = entity.getUrl();
        if (url != null) {
            stmt.bindString(4, url);
        }
        stmt.bindString(5, entity.getPkgName());
 
        String interfaceName = entity.getInterfaceName();
        if (interfaceName != null) {
            stmt.bindString(6, interfaceName);
        }
        stmt.bindLong(7, entity.getStaus());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, AppdownloadBean entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(3, icon);
        }
 
        String url = entity.getUrl();
        if (url != null) {
            stmt.bindString(4, url);
        }
        stmt.bindString(5, entity.getPkgName());
 
        String interfaceName = entity.getInterfaceName();
        if (interfaceName != null) {
            stmt.bindString(6, interfaceName);
        }
        stmt.bindLong(7, entity.getStaus());
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public AppdownloadBean readEntity(Cursor cursor, int offset) {
        AppdownloadBean entity = new AppdownloadBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // mId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // icon
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // url
            cursor.getString(offset + 4), // pkgName
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // interfaceName
            cursor.getInt(offset + 6) // staus
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, AppdownloadBean entity, int offset) {
        entity.setMId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setIcon(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setUrl(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setPkgName(cursor.getString(offset + 4));
        entity.setInterfaceName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setStaus(cursor.getInt(offset + 6));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(AppdownloadBean entity, long rowId) {
        entity.setMId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(AppdownloadBean entity) {
        if(entity != null) {
            return entity.getMId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(AppdownloadBean entity) {
        return entity.getMId() != null;
    }

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