Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / java / org / onap / vid / mso / rest / RelatedInstance.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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.vid.mso.rest;
22
23 import com.fasterxml.jackson.annotation.*;
24 import org.apache.commons.lang.builder.EqualsBuilder;
25 import org.apache.commons.lang.builder.HashCodeBuilder;
26 import org.apache.commons.lang.builder.ToStringBuilder;
27 import org.onap.vid.mso.model.ModelInfo;
28
29 import java.util.HashMap;
30 import java.util.Map;
31
32
33 /**
34  * modelInfo and optional instanceId and instanceName for a model related to the modelInfo being operated on.
35  */
36 @JsonInclude(JsonInclude.Include.NON_NULL)
37 @JsonPropertyOrder({
38     "instanceName",
39     "instanceId",
40     "modelInfo"
41 })
42 public class RelatedInstance {
43
44     /**
45      * optional name for the instance Id of the related model
46      *
47      */
48     @JsonProperty("instanceName")
49     private String instanceName;
50
51     /**
52      * instance Id for the related model
53      *
54      */
55     @JsonProperty("instanceId")
56     private String instanceId;
57
58     /** The model info. */
59     @JsonProperty("modelInfo")
60     private ModelInfo modelInfo;
61     
62     /** The additional properties. */
63     @JsonIgnore
64     private Map<String, Object> additionalProperties = new HashMap<>();
65
66     /**
67      * optional name for the instance Id of the related model
68      *
69      * @return
70      *     The instanceName
71      */
72     @JsonProperty("instanceName")
73     public String getInstanceName() {
74         return instanceName;
75     }
76
77     /**
78      * optional name for the instance Id of the related model
79      *
80      * @param instanceName
81      *     The instanceName
82      */
83     @JsonProperty("instanceName")
84     public void setInstanceName(String instanceName) {
85         this.instanceName = instanceName;
86     }
87
88     /**
89      * instance Id for the related model
90      *
91      * @return
92      *     The instanceId
93      */
94     @JsonProperty("instanceId")
95     public String getInstanceId() {
96         return instanceId;
97     }
98
99     /**
100      * instance Id for the related model
101      *
102      * @param instanceId
103      *     The instanceId
104      */
105     @JsonProperty("instanceId")
106     public void setInstanceId(String instanceId) {
107         this.instanceId = instanceId;
108     }
109
110     /**
111      * (Required).
112      *
113      * @return     The modelInfo
114      */
115     @JsonProperty("modelInfo")
116     public ModelInfo getModelInfo() {
117         return modelInfo;
118     }
119
120     /**
121      * (Required).
122      *
123      * @param modelInfo     The modelInfo
124      */
125     @JsonProperty("modelInfo")
126     public void setModelInfo(ModelInfo modelInfo) {
127         this.modelInfo = modelInfo;
128     }
129
130     /* (non-Javadoc)
131      * @see org.onap.vid.domain.mso.RelatedInstance#toString()
132      */
133     @Override
134     public String toString() {
135         return ToStringBuilder.reflectionToString(this);
136     }
137
138     /* (non-Javadoc)
139      * @see org.onap.vid.domain.mso.RelatedInstance#getAdditionalProperties()
140      */
141     @JsonAnyGetter
142     public Map<String, Object> getAdditionalProperties() {
143         return this.additionalProperties;
144     }
145
146     /* (non-Javadoc)
147      * @see org.onap.vid.domain.mso.RelatedInstance#setAdditionalProperty(java.lang.String, java.lang.Object)
148      */
149     @JsonAnySetter
150     public void setAdditionalProperty(String name, Object value) {
151         this.additionalProperties.put(name, value);
152     }
153
154     /* (non-Javadoc)
155      * @see org.onap.vid.domain.mso.RelatedInstance#hashCode()
156      */
157     @Override
158     public int hashCode() {
159         return new HashCodeBuilder().append(getInstanceName()).append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode();
160     }
161
162     /* (non-Javadoc)
163      * @see org.onap.vid.domain.mso.RelatedInstance#equals(java.lang.Object)
164      */
165     @Override
166     public boolean equals(Object other) {
167         if (other == this) {
168             return true;
169         }
170         if (!(other instanceof RelatedInstance)) {
171             return false;
172         }
173         RelatedInstance rhs = ((RelatedInstance) other);
174         return new EqualsBuilder().append(getInstanceName(), rhs.getInstanceName()).append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.getModelInfo()).append(additionalProperties, rhs.additionalProperties).isEquals();
175     }
176
177 }