Merge of new rebased code
[appc.git] / appc-common / src / main / java / org / openecomp / appc / metadata / objects / DependencyModelIdentifier.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.metadata.objects;
23
24
25 public class DependencyModelIdentifier {
26     private String vnfType;
27     private String catalogVersion;
28
29     public DependencyModelIdentifier(String vnfType, String catalogVersion){
30         this.vnfType = vnfType;
31         this.catalogVersion = catalogVersion;
32     }
33
34     public int hashCode(){
35         final int prime = 31;
36         int result = 1;
37         result = result * prime + (this.vnfType == null ? 0 :this.vnfType.hashCode());
38         result = result * prime + (this.catalogVersion == null ? 0 :this.catalogVersion.hashCode());
39         return result;
40     }
41
42     public boolean equals(Object obj){
43         if(obj ==null)
44             return false;
45         if(!(obj instanceof DependencyModelIdentifier))
46             return false;
47
48         DependencyModelIdentifier modelIdentifier = (DependencyModelIdentifier)obj;
49         if(this.vnfType == null){
50             if(modelIdentifier.vnfType !=null)
51                 return false;
52         }
53         else if(!this.vnfType.equals(modelIdentifier.vnfType))
54             return false;
55
56         if(this.catalogVersion == null){
57             if(modelIdentifier.catalogVersion !=null)
58                 return false;
59         }
60         else if(!this.catalogVersion.equals(modelIdentifier.catalogVersion))
61             return false;
62
63         return true;
64     }
65
66     @Override
67     public String toString() {
68         return "DependencyModelIdentifier : vnfType = "+vnfType + " , catalogVersion = " +catalogVersion;
69     }
70
71     public String getVnfType() {
72         return vnfType;
73     }
74
75     public String getCatalogVersion() {
76         return catalogVersion;
77     }
78
79 }