package com.popomusic.videoModel;

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.popomusic.bean.DaoSession;

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

    public static final String TABLENAME = "VIDEO_BEAN";

    /**
     * Properties of entity VideoBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property DataType = new Property(1, String.class, "dataType", false, "DATA_TYPE");
        public final static Property Title = new Property(2, String.class, "title", false, "TITLE");
        public final static Property Text = new Property(3, String.class, "text", false, "TEXT");
        public final static Property Description = new Property(4, String.class, "description", false, "DESCRIPTION");
        public final static Property Image = new Property(5, String.class, "image", false, "IMAGE");
        public final static Property ActionUrl = new Property(6, String.class, "actionUrl", false, "ACTION_URL");
        public final static Property Shade = new Property(7, boolean.class, "shade", false, "SHADE");
        public final static Property PlayUrl = new Property(8, String.class, "playUrl", false, "PLAY_URL");
        public final static Property Category = new Property(9, String.class, "category", false, "CATEGORY");
        public final static Property Duration = new Property(10, long.class, "duration", false, "DURATION");
        public final static Property Icon = new Property(11, String.class, "icon", false, "ICON");
    }


    public VideoBeanDao(DaoConfig config) {
        super(config);
    }
    
    public VideoBeanDao(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 + "\"VIDEO_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"DATA_TYPE\" TEXT," + // 1: dataType
                "\"TITLE\" TEXT," + // 2: title
                "\"TEXT\" TEXT," + // 3: text
                "\"DESCRIPTION\" TEXT," + // 4: description
                "\"IMAGE\" TEXT," + // 5: image
                "\"ACTION_URL\" TEXT," + // 6: actionUrl
                "\"SHADE\" INTEGER NOT NULL ," + // 7: shade
                "\"PLAY_URL\" TEXT," + // 8: playUrl
                "\"CATEGORY\" TEXT," + // 9: category
                "\"DURATION\" INTEGER NOT NULL ," + // 10: duration
                "\"ICON\" TEXT);"); // 11: icon
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, VideoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String dataType = entity.getDataType();
        if (dataType != null) {
            stmt.bindString(2, dataType);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(3, title);
        }
 
        String text = entity.getText();
        if (text != null) {
            stmt.bindString(4, text);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(5, description);
        }
 
        String image = entity.getImage();
        if (image != null) {
            stmt.bindString(6, image);
        }
 
        String actionUrl = entity.getActionUrl();
        if (actionUrl != null) {
            stmt.bindString(7, actionUrl);
        }
        stmt.bindLong(8, entity.getShade() ? 1L: 0L);
 
        String playUrl = entity.getPlayUrl();
        if (playUrl != null) {
            stmt.bindString(9, playUrl);
        }
 
        String category = entity.getCategory();
        if (category != null) {
            stmt.bindString(10, category);
        }
        stmt.bindLong(11, entity.getDuration());
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(12, icon);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, VideoBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String dataType = entity.getDataType();
        if (dataType != null) {
            stmt.bindString(2, dataType);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(3, title);
        }
 
        String text = entity.getText();
        if (text != null) {
            stmt.bindString(4, text);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(5, description);
        }
 
        String image = entity.getImage();
        if (image != null) {
            stmt.bindString(6, image);
        }
 
        String actionUrl = entity.getActionUrl();
        if (actionUrl != null) {
            stmt.bindString(7, actionUrl);
        }
        stmt.bindLong(8, entity.getShade() ? 1L: 0L);
 
        String playUrl = entity.getPlayUrl();
        if (playUrl != null) {
            stmt.bindString(9, playUrl);
        }
 
        String category = entity.getCategory();
        if (category != null) {
            stmt.bindString(10, category);
        }
        stmt.bindLong(11, entity.getDuration());
 
        String icon = entity.getIcon();
        if (icon != null) {
            stmt.bindString(12, icon);
        }
    }

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

    @Override
    public VideoBean readEntity(Cursor cursor, int offset) {
        VideoBean entity = new VideoBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // dataType
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // title
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // text
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // description
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // image
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // actionUrl
            cursor.getShort(offset + 7) != 0, // shade
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // playUrl
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // category
            cursor.getLong(offset + 10), // duration
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11) // icon
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, VideoBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setDataType(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setTitle(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setText(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDescription(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setImage(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setActionUrl(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setShade(cursor.getShort(offset + 7) != 0);
        entity.setPlayUrl(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setCategory(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setDuration(cursor.getLong(offset + 10));
        entity.setIcon(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(VideoBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(VideoBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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