PageRenderTime 38ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/com/jieshuhuiyou/entity/Sharing.java

https://bitbucket.org/psjay/ants-bookbase
Java | 171 lines | 136 code | 34 blank | 1 comment | 27 complexity | 16a082aa0c0d920d4c09a75525595f2d MD5 | raw file
  1. package com.jieshuhuiyou.entity;
  2. import java.io.Serializable;
  3. import java.util.Date;
  4. import javax.persistence.Column;
  5. import javax.persistence.Entity;
  6. import javax.persistence.GeneratedValue;
  7. import javax.persistence.Id;
  8. import javax.persistence.ManyToOne;
  9. import org.hibernate.annotations.Cascade;
  10. import org.hibernate.annotations.CascadeType;
  11. import com.alibaba.fastjson.annotation.JSONField;
  12. @Entity
  13. public class Sharing implements Serializable {
  14. private static final long serialVersionUID = -6034564658523627436L;
  15. @Id
  16. @GeneratedValue
  17. private int id;// ID
  18. @ManyToOne
  19. @Cascade({CascadeType.SAVE_UPDATE})
  20. private User user;// ?????
  21. @ManyToOne
  22. @Cascade({CascadeType.SAVE_UPDATE})
  23. private Book book;// ????
  24. @Column(nullable = false)
  25. private int maxBorrowDay;// ??????
  26. @Column(length = 300)
  27. private String requirements;// ??
  28. @Column(columnDefinition = "timestamp not null default current_timestamp")
  29. private Date shareDate;// ????
  30. private int borrowedTimes; // ?????
  31. private boolean avalible = true;
  32. private boolean canceled;
  33. public Sharing(){}
  34. @Override
  35. public int hashCode() {
  36. final int prime = 31;
  37. int result = 1;
  38. result = prime * result + ((book == null) ? 0 : book.hashCode());
  39. result = prime * result
  40. + ((shareDate == null) ? 0 : shareDate.hashCode());
  41. result = prime * result + ((user == null) ? 0 : user.hashCode());
  42. return result;
  43. }
  44. @Override
  45. public boolean equals(Object obj) {
  46. if (this == obj)
  47. return true;
  48. if (obj == null)
  49. return false;
  50. if (getClass() != obj.getClass())
  51. return false;
  52. Sharing other = (Sharing) obj;
  53. if (book == null) {
  54. if (other.book != null)
  55. return false;
  56. } else if (!book.equals(other.book))
  57. return false;
  58. if (shareDate == null) {
  59. if (other.shareDate != null)
  60. return false;
  61. } else if (!shareDate.equals(other.shareDate))
  62. return false;
  63. if (user == null) {
  64. if (other.user != null)
  65. return false;
  66. } else if (!user.equals(other.user))
  67. return false;
  68. return true;
  69. }
  70. // setters and getters
  71. public int getId() {
  72. return id;
  73. }
  74. public void setId(int id) {
  75. this.id = id;
  76. }
  77. public User getUser() {
  78. return user;
  79. }
  80. public void setUser(User user) {
  81. this.user = user;
  82. }
  83. public Book getBook() {
  84. return book;
  85. }
  86. public void setBook(Book book) {
  87. this.book = book;
  88. }
  89. public int getMaxBorrowDay() {
  90. return maxBorrowDay;
  91. }
  92. public void setMaxBorrowDay(int maxBorrowDay) {
  93. this.maxBorrowDay = maxBorrowDay;
  94. }
  95. @JSONField(serialize = false)
  96. public String getRequirements() {
  97. return requirements;
  98. }
  99. public void setRequirements(String requirements) {
  100. this.requirements = requirements;
  101. }
  102. public Date getShareDate() {
  103. return shareDate;
  104. }
  105. public void setShareDate(Date shareDate) {
  106. this.shareDate = shareDate;
  107. }
  108. @JSONField(serialize = false)
  109. public boolean isAvalible() {
  110. return avalible;
  111. }
  112. @JSONField(serialize = false)
  113. public boolean getAvalible() {
  114. return avalible;
  115. }
  116. public void setAvalible(boolean avalible) {
  117. this.avalible = avalible;
  118. }
  119. @JSONField(serialize = false)
  120. public int getBorrowedTimes() {
  121. return borrowedTimes;
  122. }
  123. public void setBorrowedTimes(int borrowedTimes) {
  124. this.borrowedTimes = borrowedTimes;
  125. }
  126. @JSONField(serialize = false)
  127. public boolean getCanceled() {
  128. return canceled;
  129. }
  130. @JSONField(serialize = false)
  131. public boolean isCanceled() {
  132. return canceled;
  133. }
  134. public void setCanceled(boolean canceled) {
  135. this.canceled = canceled;
  136. }
  137. }