Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / SiteStatus.java
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
24 import java.time.format.DateTimeFormatter;
25 import java.util.Date;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.PrePersist;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import java.util.Objects;
34 import org.apache.commons.lang3.builder.ToStringBuilder;
35
36 @Entity
37 @Table(name = "site_status")
38 public class SiteStatus {
39
40     @Column(name = "STATUS")
41     private boolean status;
42     @Id
43     @Column(name = "SITE_NAME")
44     private String siteName;
45     @Column(name = "CREATION_TIMESTAMP", insertable = false, updatable = false)
46     @Temporal(TemporalType.TIMESTAMP)
47     private Date created;
48
49     public SiteStatus() {}
50
51     public SiteStatus(String siteName) {
52         this.siteName = siteName;
53     }
54
55     public Date getCreated() {
56         return created;
57     }
58
59     public String getSiteName() {
60         return siteName;
61     }
62
63     public void setSiteName(String siteName) {
64         this.siteName = siteName;
65     }
66
67     public void setStatus(boolean status) {
68         this.status = status;
69     }
70
71     public boolean getStatus() {
72         return status;
73     }
74
75     @PrePersist
76     protected void createdAt() {
77         this.created = new Date();
78     }
79
80     @Override
81     public boolean equals(final Object other) {
82         if (this == other) {
83             return true;
84         }
85         if (!(other instanceof SiteStatus)) {
86             return false;
87         }
88         SiteStatus castOther = (SiteStatus) other;
89         return Objects.equals(getSiteName(), castOther.getSiteName());
90     }
91
92     @Override
93     public int hashCode() {
94         return Objects.hash(getSiteName());
95     }
96
97     @Override
98     public String toString() {
99         return new ToStringBuilder(this).append("status", getStatus()).append("siteName", getSiteName())
100                 .append("created", getCreated()).toString();
101     }
102 }