package com.tutorial.findtaxis.model.bean;

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

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import com.tutorial.findtaxis.model.bean.Tags;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table TAGS.
*/
public class TagsDao extends AbstractDao<Tags, Long> {

    public static final String TABLENAME = "TAGS";

    /**
     * Properties of entity Tags.<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 Marca = new Property(1, String.class, "Marca", false, "MARCA");
        public final static Property Modelo = new Property(2, String.class, "Modelo", false, "MODELO");
        public final static Property NombreChofer = new Property(3, String.class, "nombreChofer", false, "NOMBRE_CHOFER");
        public final static Property ApellidoChofer = new Property(4, String.class, "apellidoChofer", false, "APELLIDO_CHOFER");
    };


    public TagsDao(DaoConfig config) {
        super(config);
    }
    
    public TagsDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "'TAGS' (" + //
                "'_id' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "'MARCA' TEXT," + // 1: Marca
                "'MODELO' TEXT," + // 2: Modelo
                "'NOMBRE_CHOFER' TEXT," + // 3: nombreChofer
                "'APELLIDO_CHOFER' TEXT);"); // 4: apellidoChofer
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, Tags entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String Marca = entity.getMarca();
        if (Marca != null) {
            stmt.bindString(2, Marca);
        }
 
        String Modelo = entity.getModelo();
        if (Modelo != null) {
            stmt.bindString(3, Modelo);
        }
 
        String nombreChofer = entity.getNombreChofer();
        if (nombreChofer != null) {
            stmt.bindString(4, nombreChofer);
        }
 
        String apellidoChofer = entity.getApellidoChofer();
        if (apellidoChofer != null) {
            stmt.bindString(5, apellidoChofer);
        }
    }

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

    /** @inheritdoc */
    @Override
    public Tags readEntity(Cursor cursor, int offset) {
        Tags entity = new Tags( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // Marca
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // Modelo
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // nombreChofer
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // apellidoChofer
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, Tags entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setMarca(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setModelo(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setNombreChofer(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setApellidoChofer(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
     }
    
    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(Tags entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    /** @inheritdoc */
    @Override
    public Long getKey(Tags entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}
