Last active
November 12, 2017 20:57
-
-
Save derfalx/e03e77cc15900517d23bb41a1033501d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.greenrobot.greendao.DaoException; | |
import org.greenrobot.greendao.annotation.Entity; | |
import org.greenrobot.greendao.annotation.Generated; | |
import org.greenrobot.greendao.annotation.Id; | |
import org.greenrobot.greendao.annotation.NotNull; | |
import org.greenrobot.greendao.annotation.ToOne; | |
import java.util.Date; | |
/** | |
* @author <a href="mailto:kschneider@codingfalx.de">Kristoffer Schneider alias falx<a> | |
*/ | |
@Entity(active = true) | |
public class MessageEntity extends BaseEntity { | |
private static final String TAG = MessageEntity.class.getSimpleName(); | |
@Id | |
private Long id; | |
@NotNull | |
private String sender; | |
@NotNull | |
private Date timeStamp; | |
@NotNull | |
private String message; | |
@NotNull | |
@ToOne(joinProperty = "channelId") | |
private ChannelEntity channel; | |
private Long channelId; | |
/** | |
* Used to resolve relations | |
*/ | |
@Generated(hash = 2040040024) | |
private transient DaoSession daoSession; | |
/** | |
* Used for active entity operations. | |
*/ | |
@Generated(hash = 499759967) | |
private transient MessageEntityDao myDao; | |
@Generated(hash = 575478453) | |
private transient Long channel__resolvedKey; | |
@Generated(hash = 525590421) | |
public MessageEntity(Long id, @NotNull String sender, @NotNull Date timeStamp, | |
@NotNull String message, Long channelId) { | |
this.id = id; | |
this.sender = sender; | |
this.timeStamp = timeStamp; | |
this.message = message; | |
this.channelId = channelId; | |
} | |
@Generated(hash = 1797882234) | |
public MessageEntity() { | |
} | |
public Long getId() { | |
return this.id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public String getSender() { | |
return this.sender; | |
} | |
public void setSender(String sender) { | |
this.sender = sender; | |
} | |
public Date getTimeStamp() { | |
return this.timeStamp; | |
} | |
public void setTimeStamp(Date timeStamp) { | |
this.timeStamp = timeStamp; | |
} | |
public String getMessage() { | |
return this.message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
/** | |
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}. | |
* Entity must attached to an entity context. | |
*/ | |
@Generated(hash = 128553479) | |
public void delete() { | |
if (myDao == null) { | |
throw new DaoException("Entity is detached from DAO context"); | |
} | |
myDao.delete(this); | |
} | |
/** | |
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}. | |
* Entity must attached to an entity context. | |
*/ | |
@Generated(hash = 1942392019) | |
public void refresh() { | |
if (myDao == null) { | |
throw new DaoException("Entity is detached from DAO context"); | |
} | |
myDao.refresh(this); | |
} | |
/** | |
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}. | |
* Entity must attached to an entity context. | |
*/ | |
@Generated(hash = 713229351) | |
public void update() { | |
if (myDao == null) { | |
throw new DaoException("Entity is detached from DAO context"); | |
} | |
myDao.update(this); | |
} | |
public Long getChannelId() { | |
return this.channelId; | |
} | |
public void setChannelId(Long channelId) { | |
this.channelId = channelId; | |
} | |
/** | |
* To-one relationship, resolved on first access. | |
*/ | |
@Generated(hash = 1570739365) | |
public ChannelEntity getChannel() { | |
Long __key = this.channelId; | |
if (channel__resolvedKey == null || !channel__resolvedKey.equals(__key)) { | |
final DaoSession daoSession = this.daoSession; | |
if (daoSession == null) { | |
throw new DaoException("Entity is detached from DAO context"); | |
} | |
ChannelEntityDao targetDao = daoSession.getChannelEntityDao(); | |
ChannelEntity channelNew = targetDao.load(__key); | |
synchronized (this) { | |
channel = channelNew; | |
channel__resolvedKey = __key; | |
} | |
} | |
return channel; | |
} | |
/** | |
* called by internal mechanisms, do not call yourself. | |
*/ | |
@Generated(hash = 469215866) | |
public void setChannel(ChannelEntity channel) { | |
synchronized (this) { | |
this.channel = channel; | |
channelId = channel == null ? null : channel.getId(); | |
channel__resolvedKey = channelId; | |
} | |
} | |
/** called by internal mechanisms, do not call yourself. */ | |
@Generated(hash = 83651317) | |
public void __setDaoSession(DaoSession daoSession) { | |
this.daoSession = daoSession; | |
myDao = daoSession != null ? daoSession.getMessageEntityDao() : null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment