Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Price {
- @NonNull
- private Double price;
- @NonNull
- private Date date;
- public Price(Double price, Date date) {
- Log.e("TEST3", "Asset price " + price + " " + date.toString());
- this.price = price;
- this.date = date;
- }
- public Double getPrice() {
- return price;
- }
- public void setPrice(Double price) {
- this.price = price;
- }
- public Date getDate() {
- return date;
- }
- public void setDate(Date date) {
- this.date = date;
- }
- }
- public abstract class PriceHistory {
- @NonNull
- @Embedded
- private Price price;
- @NonNull
- @TypeConverters(TimestampConverter.class)
- @ColumnInfo(name = "last_updated_timestamp")
- private Timestamp lastUpdatedTimestamp;
- @Ignore
- public PriceHistory(@NonNull Price price) {
- this.price = price;
- this.lastUpdatedTimestamp = DateTimeUtil.getCurrentTimestamp();
- }
- public PriceHistory(@NonNull Price price, @NonNull Timestamp lastUpdatedTimestamp) {
- this.price = price;
- this.lastUpdatedTimestamp = lastUpdatedTimestamp;
- }
- @NonNull
- public Price getPrice() {
- return price;
- }
- public void setPrice(@NonNull Price price) {
- this.price = price;
- }
- @NonNull
- public Timestamp getLastUpdatedTimestamp() {
- return lastUpdatedTimestamp;
- }
- public void setLastUpdatedTimestamp(@NonNull Timestamp lastUpdatedTimestamp) {
- this.lastUpdatedTimestamp = lastUpdatedTimestamp;
- }
- }
- @Entity(tableName = "specific_price_history", primaryKeys = {"code", "date"})
- public class SpecificPriceHistory extends PriceHistory {
- @NonNull
- private String code;
- @Ignore
- public SpecificPriceHistory(@NonNull String code, @NonNull Price price) {
- super(price);
- this.code = code;
- }
- public SpecificPriceHistory(@NonNull Price price, @NonNull Timestamp lastUpdatedTimestamp, @NonNull String code) {
- super(price, lastUpdatedTimestamp);
- if(price == null) {
- Log.e("TEST2", "Still getting null");
- }
- this.code = code;
- }
- @NonNull
- public String getCode() {
- return code;
- }
- public void setCode(@NonNull String code) {
- this.code = code;
- }
- }
- @Query("SELECT * FROM specific_price_history WHERE code = :code ORDER BY date ASC")
- public abstract List<SpecificPriceHistory> listHistory(String code);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement