Newer
Older
Endoscope / app / src / main / java / com / casic / endoscope / greendao / CameraPointBeanDao.java
package com.casic.endoscope.greendao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import com.casic.endoscope.bean.CameraPointBean;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.internal.DaoConfig;

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

    public static final String TABLENAME = "CAMERA_POINT_BEAN";

    /**
     * Properties of entity CameraPointBean.<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 HAngle = new Property(1, int.class, "hAngle", false, "H_ANGLE");
        public final static Property VAngle = new Property(2, int.class, "vAngle", false, "V_ANGLE");
    }


    public CameraPointBeanDao(DaoConfig config) {
        super(config);
    }
    
    public CameraPointBeanDao(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 + "\"CAMERA_POINT_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"H_ANGLE\" INTEGER NOT NULL ," + // 1: hAngle
                "\"V_ANGLE\" INTEGER NOT NULL );"); // 2: vAngle
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, CameraPointBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindLong(2, entity.getHAngle());
        stmt.bindLong(3, entity.getVAngle());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, CameraPointBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindLong(2, entity.getHAngle());
        stmt.bindLong(3, entity.getVAngle());
    }

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

    @Override
    public CameraPointBean readEntity(Cursor cursor, int offset) {
        CameraPointBean entity = new CameraPointBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.getInt(offset + 1), // hAngle
            cursor.getInt(offset + 2) // vAngle
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, CameraPointBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setHAngle(cursor.getInt(offset + 1));
        entity.setVAngle(cursor.getInt(offset + 2));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(CameraPointBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(CameraPointBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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