##### Coverage Report - com.ctrip.framework.apollo.common.entity.BaseEntity

Classes in this File | Line Coverage | Branch Coverage | Complexity
BaseEntity |
0% | 0/33
0% | 0/4
| 1.1176470588235294;1.118

1 |  |
     package com.ctrip.framework.apollo.common.entity;
2 |  |
3 |  |
     import java.util.Date;
4 |  |
5 |  |
     import javax.persistence.Column;
6 |  |
     import javax.persistence.GeneratedValue;
7 |  |
     import javax.persistence.Id;
8 |  |
     import javax.persistence.Inheritance;
9 |  |
     import javax.persistence.InheritanceType;
10 |  |
     import javax.persistence.MappedSuperclass;
11 |  |
     import javax.persistence.PrePersist;
12 |  |
     import javax.persistence.PreRemove;
13 |  |
     import javax.persistence.PreUpdate;
14 |  |
15 |  |
     import com.google.common.base.MoreObjects;
16 |  |
     import com.google.common.base.MoreObjects.ToStringHelper;
17 |  |
18 |  |
     @MappedSuperclass
19 |  |
     @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
20 | 0 |
     public abstract class BaseEntity {
21 |  |
22 |  |
       @Id
23 |  |
       @GeneratedValue
24 |  |
       @Column(name = "Id")
25 |  |
       private long id;
26 |  |
27 | 0 |
       @Column(name = "IsDeleted", columnDefinition = "Bit default '0'")
28 |  |
       protected boolean isDeleted = false;
29 |  |
30 |  |
       @Column(name = "DataChange_CreatedBy", nullable = false)
31 |  |
       private String dataChangeCreatedBy;
32 |  |
33 |  |
       @Column(name = "DataChange_CreatedTime", nullable = false)
34 |  |
       private Date dataChangeCreatedTime;
35 |  |
36 |  |
       @Column(name = "DataChange_LastModifiedBy")
37 |  |
       private String dataChangeLastModifiedBy;
38 |  |
39 |  |
       @Column(name = "DataChange_LastTime")
40 |  |
       private Date dataChangeLastModifiedTime;
41 |  |
42 |  |
       public String getDataChangeCreatedBy() {
43 | 0 |
         return dataChangeCreatedBy;
44 |  |
       }
45 |  |
46 |  |
       public Date getDataChangeCreatedTime() {
47 | 0 |
         return dataChangeCreatedTime;
48 |  |
       }
49 |  |
50 |  |
       public String getDataChangeLastModifiedBy() {
51 | 0 |
         return dataChangeLastModifiedBy;
52 |  |
       }
53 |  |
54 |  |
       public Date getDataChangeLastModifiedTime() {
55 | 0 |
         return dataChangeLastModifiedTime;
56 |  |
       }
57 |  |
58 |  |
       public long getId() {
59 | 0 |
         return id;
60 |  |
       }
61 |  |
62 |  |
       public boolean isDeleted() {
63 | 0 |
         return isDeleted;
64 |  |
       }
65 |  |
66 |  |
       public void setDataChangeCreatedBy(String dataChangeCreatedBy) {
67 | 0 |
         this.dataChangeCreatedBy = dataChangeCreatedBy;
68 | 0 |
       }
69 |  |
70 |  |
       public void setDataChangeCreatedTime(Date dataChangeCreatedTime) {
71 | 0 |
         this.dataChangeCreatedTime = dataChangeCreatedTime;
72 | 0 |
       }
73 |  |
74 |  |
       public void setDataChangeLastModifiedBy(String dataChangeLastModifiedBy) {
75 | 0 |
         this.dataChangeLastModifiedBy = dataChangeLastModifiedBy;
76 | 0 |
       }
77 |  |
78 |  |
       public void setDataChangeLastModifiedTime(Date dataChangeLastModifiedTime) {
79 | 0 |
         this.dataChangeLastModifiedTime = dataChangeLastModifiedTime;
80 | 0 |
       }
81 |  |
82 |  |
       public void setDeleted(boolean deleted) {
83 | 0 |
         isDeleted = deleted;
84 | 0 |
       }
85 |  |
86 |  |
       public void setId(long id) {
87 | 0 |
         this.id = id;
88 | 0 |
       }
89 |  |
90 |  |
       @PrePersist
91 |  |
       protected void prePersist() {
92 | 0 |
         if (this.dataChangeCreatedTime == null) dataChangeCreatedTime = new Date();
93 | 0 |
         if (this.dataChangeLastModifiedTime == null) dataChangeLastModifiedTime = new Date();
94 | 0 |
       }
95 |  |
96 |  |
       @PreUpdate
97 |  |
       protected void preUpdate() {
98 | 0 |
         this.dataChangeLastModifiedTime = new Date();
99 | 0 |
       }
100 |  |
101 |  |
       @PreRemove
102 |  |
       protected void preRemove() {
103 | 0 |
         this.dataChangeLastModifiedTime = new Date();
104 | 0 |
       }
105 |  |
106 |  |
       protected ToStringHelper toStringHelper() {
107 | 0 |
         return MoreObjects.toStringHelper(this).omitNullValues().add("id", id)
108 | 0 |
             .add("dataChangeCreatedBy", dataChangeCreatedBy)
109 | 0 |
             .add("dataChangeCreatedTime", dataChangeCreatedTime)
110 | 0 |
             .add("dataChangeLastModifiedBy", dataChangeLastModifiedBy)
111 | 0 |
             .add("dataChangeLastModifiedTime", dataChangeLastModifiedTime);
112 |  |
       }
113 |  |
114 |  |
       public String toString(){
115 | 0 |
         return toStringHelper().toString();
116 |  |
       }
117 |  |
     }