package com.cc.infosur.greendao;

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;


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

    public static final String TABLENAME = "DAY_SERVICE_REL";

    /**
     * Properties of entity DayServiceRel.<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 Day = new Property(1, Long.class, "day", false, "DAY");
        public final static Property Service = new Property(2, Long.class, "service", false, "SERVICE");
        public final static Property Order = new Property(3, Integer.class, "order", false, "ORDER");
    };


    public DayServiceRelDao(DaoConfig config) {
        super(config);
    }
    
    public DayServiceRelDao(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 + "'DAY_SERVICE_REL' (" + //
                "'_id' INTEGER PRIMARY KEY ," + // 0: id
                "'DAY' INTEGER," + // 1: day
                "'SERVICE' INTEGER," + // 2: service
                "'ORDER' INTEGER);"); // 3: order
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, DayServiceRel entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long day = entity.getDay();
        if (day != null) {
            stmt.bindLong(2, day);
        }
 
        Long service = entity.getService();
        if (service != null) {
            stmt.bindLong(3, service);
        }
 
        Integer order = entity.getOrder();
        if (order != null) {
            stmt.bindLong(4, order);
        }
    }

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

    /** @inheritdoc */
    @Override
    public DayServiceRel readEntity(Cursor cursor, int offset) {
        DayServiceRel entity = new DayServiceRel( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // day
            cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // service
            cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3) // order
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, DayServiceRel entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setDay(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setService(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
        entity.setOrder(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
     }
    
    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(DayServiceRel entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    /** @inheritdoc */
    @Override
    public Long getKey(DayServiceRel entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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