package com.cc.infosur.greendao;

import java.util.List;
import de.greenrobot.dao.DaoException;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 
/**
 * Entity mapped to table TRAVELLER_INFO.
 */
public class TravellerInfo {

    private Long id;
    private String email;
    private String password;

    /** Used to resolve relations */
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    private transient TravellerInfoDao myDao;

    private List<TripInfo> trips;

    public TravellerInfo() {
    }

    public TravellerInfo(Long id) {
        this.id = id;
    }

    public TravellerInfo(Long id, String email, String password) {
        this.id = id;
        this.email = email;
        this.password = password;
    }

    /** called by internal mechanisms, do not call yourself. */
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getTravellerInfoDao() : null;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
    public List<TripInfo> getTrips() {
        if (trips == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            TripInfoDao targetDao = daoSession.getTripInfoDao();
            List<TripInfo> tripsNew = targetDao._queryTravellerInfo_Trips(id);
            synchronized (this) {
                if(trips == null) {
                    trips = tripsNew;
                }
            }
        }
        return trips;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    public synchronized void resetTrips() {
        trips = null;
    }

    /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.delete(this);
    }

    /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.update(this);
    }

    /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }    
        myDao.refresh(this);
    }

}
