Initial OpenECOMP MSO commit
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / VnfComponent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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.openecomp.mso.db.catalog.beans;
22
23
24
25 import java.sql.Timestamp;
26 import java.text.DateFormat;
27
28 import java.io.Serializable;
29
30 public class VnfComponent implements Serializable {
31     private int vnfId;
32     private String componentType = null;
33     private Integer heatTemplateId;
34     private Integer heatEnvironmentId;
35     public static final long serialVersionUID = -1322322139926390329L;
36
37         private Timestamp created;
38     
39     public VnfComponent() {}
40
41     public int getVnfId() {
42         return vnfId;
43     }
44     public void setVnfId(int id) {
45         this.vnfId = id;
46     }
47
48     public String getComponentType() {
49         return componentType;
50     }
51     public void setComponentType(String ct) {
52         this.componentType = ct;
53     }
54
55     public Integer getHeatTemplateId() {
56         return heatTemplateId;
57     }
58     public void setHeatTemplateId(Integer ht) {
59         this.heatTemplateId = ht;
60     }
61
62     public Integer getHeatEnvironmentId() {
63         return heatEnvironmentId;
64     }
65     public void setHeatEnvironmentId(Integer he) {
66         this.heatEnvironmentId = he;
67     }
68
69         public Timestamp getCreated() {
70                 return created;
71         }
72
73         public void setCreated(Timestamp created) {
74                 this.created = created;
75         }
76     
77     @Override
78     public String toString() {
79         StringBuilder sb = new StringBuilder();
80         sb.append("VnfComponent: ");
81         sb.append("vnfId=" + vnfId);
82         sb.append(",componentType=" + componentType);
83         sb.append(",heatTemplateId=" + heatTemplateId);
84         sb.append(",heatEnvironmentId=" + heatEnvironmentId);
85         
86         if (created != null) {
87                 sb.append (",created=");
88                 sb.append (DateFormat.getInstance().format(created));
89             }
90         return sb.toString();
91     }
92     
93     @Override
94     public boolean equals (Object o) {
95         if (!(o instanceof VnfComponent)) {
96             return false;
97         }
98         if (this == o) {
99             return true;
100         }
101         VnfComponent vnfComponent = (VnfComponent) o;
102         if (vnfComponent.getVnfId() == this.vnfId && vnfComponent.componentType.equalsIgnoreCase(this.componentType)) {
103             return true;
104         }
105         return false;
106     }
107
108     @Override
109     public int hashCode () {
110         // return the hashCode of the concat string of type+vnfId - should be okay.
111         int result = 0;
112         result = (this.componentType + this.vnfId).toString().hashCode();
113         return result;
114     }
115 }