ca5ae7bbb6e6cf9f64bc224bd4c317e9b301b158
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.db.request.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.Id;
28 import javax.persistence.PrePersist;
29 import javax.persistence.PreUpdate;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Version;
34 import java.util.Objects;
35 import org.apache.commons.lang3.builder.ToStringBuilder;
36
37 @Entity
38 @Table(name = "watchdog_distributionid_status")
39 public class WatchdogDistributionStatus implements Serializable {
40
41     /**
42      * Serialization id.
43      */
44     private static final long serialVersionUID = -4449711060885719079L;
45
46     @Id
47     @Column(name = "DISTRIBUTION_ID", length = 45)
48     private String distributionId;
49     @Column(name = "DISTRIBUTION_ID_STATUS", length = 45)
50     private String distributionIdStatus;
51     @Column(name = "CREATE_TIME", updatable = false)
52     @Temporal(TemporalType.TIMESTAMP)
53     private Date createTime;
54     @Column(name = "MODIFY_TIME")
55     @Temporal(TemporalType.TIMESTAMP)
56     private Date modifyTime;
57     @Column(name = "LOCK_VERSION")
58     private int version;
59
60     public WatchdogDistributionStatus() {
61
62     }
63
64     public WatchdogDistributionStatus(String distributionId) {
65         this.distributionId = distributionId;
66     }
67
68     public String getDistributionId() {
69         return distributionId;
70     }
71
72     public void setDistributionId(String distributionId) {
73         this.distributionId = distributionId;
74     }
75
76     public String getDistributionIdStatus() {
77         return distributionIdStatus;
78     }
79
80     public void setDistributionIdStatus(String distributionIdStatus) {
81         this.distributionIdStatus = distributionIdStatus;
82     }
83
84     public int getVersion() {
85         return version;
86     }
87
88     public void setVersion(int version) {
89         this.version = version;
90     }
91
92     public Date getCreateTime() {
93         return createTime;
94     }
95
96     public Date getModifyTime() {
97         return modifyTime;
98     }
99
100     @PrePersist
101     protected void onCreate() {
102         this.createTime = this.modifyTime = new Date();
103     }
104
105     @PreUpdate
106     protected void onUpdate() {
107         this.modifyTime = new Date();
108     }
109
110     @Override
111     public boolean equals(final Object other) {
112         if (this == other) {
113             return true;
114         }
115         if (!(other instanceof WatchdogDistributionStatus)) {
116             return false;
117         }
118         WatchdogDistributionStatus castOther = (WatchdogDistributionStatus) other;
119         return Objects.equals(getDistributionId(), castOther.getDistributionId());
120     }
121
122     @Override
123     public int hashCode() {
124         return Objects.hash(getDistributionId());
125     }
126
127     @Override
128     public String toString() {
129         return new ToStringBuilder(this).append("distributionId", getDistributionId())
130                 .append("distributionIdStatus", getDistributionIdStatus()).append("createTime", getCreateTime())
131                 .append("modifyTime", getModifyTime()).toString();
132     }
133
134 }