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