package com.adins.mss.dao;

import android.database.Cursor;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;

import com.adins.mss.dao.PaymentChannel;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "MS_PAYMENTCHANNEL".
*/
public class PaymentChannelDao extends AbstractDao<PaymentChannel, String> {

    public static final String TABLENAME = "MS_PAYMENTCHANNEL";

    /**
     * Properties of entity PaymentChannel.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Uuid_paymentchannel = new Property(0, String.class, "uuid_paymentchannel", true, "UUID_PAYMENTCHANNEL");
        public final static Property Usr_crt = new Property(1, String.class, "usr_crt", false, "USR_CRT");
        public final static Property Dtm_crt = new Property(2, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
        public final static Property Is_active = new Property(3, String.class, "is_active", false, "IS_ACTIVE");
        public final static Property Code = new Property(4, String.class, "code", false, "CODE");
        public final static Property Description = new Property(5, String.class, "description", false, "DESCRIPTION");
        public final static Property Payment_limit = new Property(6, Double.class, "payment_limit", false, "PAYMENT_LIMIT");
    };


    public PaymentChannelDao(DaoConfig config) {
        super(config);
    }
    
    public PaymentChannelDao(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 + "\"MS_PAYMENTCHANNEL\" (" + //
                "\"UUID_PAYMENTCHANNEL\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_paymentchannel
                "\"USR_CRT\" TEXT," + // 1: usr_crt
                "\"DTM_CRT\" INTEGER," + // 2: dtm_crt
                "\"IS_ACTIVE\" TEXT," + // 3: is_active
                "\"CODE\" TEXT," + // 4: code
                "\"DESCRIPTION\" TEXT," + // 5: description
                "\"PAYMENT_LIMIT\" REAL);"); // 6: payment_limit
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(DatabaseStatement stmt, PaymentChannel entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUuid_paymentchannel());
 
        String usr_crt = entity.getUsr_crt();
        if (usr_crt != null) {
            stmt.bindString(2, usr_crt);
        }
 
        java.util.Date dtm_crt = entity.getDtm_crt();
        if (dtm_crt != null) {
            stmt.bindLong(3, dtm_crt.getTime());
        }
 
        String is_active = entity.getIs_active();
        if (is_active != null) {
            stmt.bindString(4, is_active);
        }
 
        String code = entity.getCode();
        if (code != null) {
            stmt.bindString(5, code);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(6, description);
        }
 
        Double payment_limit = entity.getPayment_limit();
        if (payment_limit != null) {
            stmt.bindDouble(7, payment_limit);
        }
    }

    /** @inheritdoc */
    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public PaymentChannel readEntity(Cursor cursor, int offset) {
        PaymentChannel entity = new PaymentChannel( //
            cursor.getString(offset + 0), // uuid_paymentchannel
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // usr_crt
            cursor.isNull(offset + 2) ? null : new java.util.Date(cursor.getLong(offset + 2)), // dtm_crt
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // is_active
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // code
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // description
            cursor.isNull(offset + 6) ? null : cursor.getDouble(offset + 6) // payment_limit
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, PaymentChannel entity, int offset) {
        entity.setUuid_paymentchannel(cursor.getString(offset + 0));
        entity.setUsr_crt(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setDtm_crt(cursor.isNull(offset + 2) ? null : new java.util.Date(cursor.getLong(offset + 2)));
        entity.setIs_active(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCode(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setDescription(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setPayment_limit(cursor.isNull(offset + 6) ? null : cursor.getDouble(offset + 6));
     }
    
    /** @inheritdoc */
    @Override
    protected String updateKeyAfterInsert(PaymentChannel entity, long rowId) {
        return entity.getUuid_paymentchannel();
    }
    
    /** @inheritdoc */
    @Override
    public String getKey(PaymentChannel entity) {
        if(entity != null) {
            return entity.getUuid_paymentchannel();
        } else {
            return null;
        }
    }

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