Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. public class Price {
  2. @NonNull
  3. private Double price;
  4.  
  5. @NonNull
  6. private Date date;
  7.  
  8. public Price(Double price, Date date) {
  9. Log.e("TEST3", "Asset price " + price + " " + date.toString());
  10. this.price = price;
  11. this.date = date;
  12. }
  13.  
  14. public Double getPrice() {
  15. return price;
  16. }
  17.  
  18. public void setPrice(Double price) {
  19. this.price = price;
  20. }
  21.  
  22. public Date getDate() {
  23. return date;
  24. }
  25.  
  26. public void setDate(Date date) {
  27. this.date = date;
  28. }
  29. }
  30.  
  31. public abstract class PriceHistory {
  32. @NonNull
  33. @Embedded
  34. private Price price;
  35.  
  36. @NonNull
  37. @TypeConverters(TimestampConverter.class)
  38. @ColumnInfo(name = "last_updated_timestamp")
  39. private Timestamp lastUpdatedTimestamp;
  40.  
  41. @Ignore
  42. public PriceHistory(@NonNull Price price) {
  43. this.price = price;
  44. this.lastUpdatedTimestamp = DateTimeUtil.getCurrentTimestamp();
  45. }
  46.  
  47. public PriceHistory(@NonNull Price price, @NonNull Timestamp lastUpdatedTimestamp) {
  48. this.price = price;
  49. this.lastUpdatedTimestamp = lastUpdatedTimestamp;
  50. }
  51.  
  52. @NonNull
  53. public Price getPrice() {
  54. return price;
  55. }
  56.  
  57. public void setPrice(@NonNull Price price) {
  58. this.price = price;
  59. }
  60.  
  61. @NonNull
  62. public Timestamp getLastUpdatedTimestamp() {
  63. return lastUpdatedTimestamp;
  64. }
  65.  
  66. public void setLastUpdatedTimestamp(@NonNull Timestamp lastUpdatedTimestamp) {
  67. this.lastUpdatedTimestamp = lastUpdatedTimestamp;
  68. }
  69. }
  70.  
  71. @Entity(tableName = "specific_price_history", primaryKeys = {"code", "date"})
  72. public class SpecificPriceHistory extends PriceHistory {
  73. @NonNull
  74. private String code;
  75.  
  76. @Ignore
  77. public SpecificPriceHistory(@NonNull String code, @NonNull Price price) {
  78. super(price);
  79. this.code = code;
  80. }
  81.  
  82. public SpecificPriceHistory(@NonNull Price price, @NonNull Timestamp lastUpdatedTimestamp, @NonNull String code) {
  83. super(price, lastUpdatedTimestamp);
  84. if(price == null) {
  85. Log.e("TEST2", "Still getting null");
  86. }
  87.  
  88. this.code = code;
  89. }
  90.  
  91. @NonNull
  92. public String getCode() {
  93. return code;
  94. }
  95.  
  96. public void setCode(@NonNull String code) {
  97. this.code = code;
  98. }
  99. }
  100.  
  101. @Query("SELECT * FROM specific_price_history WHERE code = :code ORDER BY date ASC")
  102. public abstract List<SpecificPriceHistory> listHistory(String code);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement