package zql.app_jinnang.greendao.db;

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 zql.app_jinnang.Bean.NoteBean;

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

    public static final String TABLENAME = "NOTE_BEAN";

    /**
     * Properties of entity NoteBean.<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 Noteinfo = new Property(1, String.class, "noteinfo", false, "NOTEINFO");
        public final static Property Notetype = new Property(2, String.class, "notetype", false, "NOTETYPE");
        public final static Property People = new Property(3, String.class, "people", false, "PEOPLE");
        public final static Property Date = new Property(4, String.class, "date", false, "DATE");
        public final static Property Time = new Property(5, String.class, "time", false, "TIME");
        public final static Property Location = new Property(6, String.class, "location", false, "LOCATION");
        public final static Property Photopath = new Property(7, String.class, "photopath", false, "PHOTOPATH");
        public final static Property Isshow = new Property(8, Boolean.class, "isshow", false, "ISSHOW");
        public final static Property Createtime = new Property(9, String.class, "createtime", false, "CREATETIME");
    }


    public NoteBeanDao(DaoConfig config) {
        super(config);
    }
    
    public NoteBeanDao(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 + "\"NOTE_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"NOTEINFO\" TEXT," + // 1: noteinfo
                "\"NOTETYPE\" TEXT," + // 2: notetype
                "\"PEOPLE\" TEXT," + // 3: people
                "\"DATE\" TEXT," + // 4: date
                "\"TIME\" TEXT," + // 5: time
                "\"LOCATION\" TEXT," + // 6: location
                "\"PHOTOPATH\" TEXT," + // 7: photopath
                "\"ISSHOW\" INTEGER," + // 8: isshow
                "\"CREATETIME\" TEXT);"); // 9: createtime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, NoteBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String noteinfo = entity.getNoteinfo();
        if (noteinfo != null) {
            stmt.bindString(2, noteinfo);
        }
 
        String notetype = entity.getNotetype();
        if (notetype != null) {
            stmt.bindString(3, notetype);
        }
 
        String people = entity.getPeople();
        if (people != null) {
            stmt.bindString(4, people);
        }
 
        String date = entity.getDate();
        if (date != null) {
            stmt.bindString(5, date);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(6, time);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(7, location);
        }
 
        String photopath = entity.getPhotopath();
        if (photopath != null) {
            stmt.bindString(8, photopath);
        }
 
        Boolean isshow = entity.getIsshow();
        if (isshow != null) {
            stmt.bindLong(9, isshow ? 1L: 0L);
        }
 
        String createtime = entity.getCreatetime();
        if (createtime != null) {
            stmt.bindString(10, createtime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, NoteBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String noteinfo = entity.getNoteinfo();
        if (noteinfo != null) {
            stmt.bindString(2, noteinfo);
        }
 
        String notetype = entity.getNotetype();
        if (notetype != null) {
            stmt.bindString(3, notetype);
        }
 
        String people = entity.getPeople();
        if (people != null) {
            stmt.bindString(4, people);
        }
 
        String date = entity.getDate();
        if (date != null) {
            stmt.bindString(5, date);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(6, time);
        }
 
        String location = entity.getLocation();
        if (location != null) {
            stmt.bindString(7, location);
        }
 
        String photopath = entity.getPhotopath();
        if (photopath != null) {
            stmt.bindString(8, photopath);
        }
 
        Boolean isshow = entity.getIsshow();
        if (isshow != null) {
            stmt.bindLong(9, isshow ? 1L: 0L);
        }
 
        String createtime = entity.getCreatetime();
        if (createtime != null) {
            stmt.bindString(10, createtime);
        }
    }

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

    @Override
    public NoteBean readEntity(Cursor cursor, int offset) {
        NoteBean entity = new NoteBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // noteinfo
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // notetype
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // people
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // date
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // time
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // location
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // photopath
            cursor.isNull(offset + 8) ? null : cursor.getShort(offset + 8) != 0, // isshow
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // createtime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, NoteBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setNoteinfo(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setNotetype(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setPeople(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDate(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setTime(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setLocation(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setPhotopath(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setIsshow(cursor.isNull(offset + 8) ? null : cursor.getShort(offset + 8) != 0);
        entity.setCreatetime(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(NoteBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(NoteBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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