Changes for checkstyle 8.32
[policy/apex-pdp.git] / core / core-protocols / src / main / java / org / onap / policy / apex / core / protocols / engdep / messages / EngineServiceInfoResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.core.protocols.engdep.messages;
22
23 import java.util.Arrays;
24 import java.util.Collection;
25 import org.onap.policy.apex.core.protocols.Message;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
27
28 /**
29  * The Class Response is a message that holds the response by an Apex engine to another Actino message sent to that
30  * engine.
31  *
32  * @author Liam Fallon (liam.fallon@ericsson.com)
33  */
34 public class EngineServiceInfoResponse extends Response {
35     private static final long serialVersionUID = -7895025789667402067L;
36
37     // The engine service key
38     private AxArtifactKey engineServiceKey;
39
40     // The engines under the control of this engine service
41     private AxArtifactKey[] engineKeyArray;
42
43     // The engine service key
44     private AxArtifactKey apexModelKey;
45
46     /**
47      * Instantiates a new EngineServiceInfoResponse message.
48      *
49      * @param targetKey the target key of the entity that asked for the action that triggered this response message
50      * @param successful the successful if the action in the triggering message worked
51      * @param responseTo the message to which this message is a response
52      */
53     public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful,
54             final Message responseTo) {
55         super(targetKey, successful, null, responseTo);
56     }
57
58     /**
59      * Instantiates a new EngineServiceInfoResponse message.
60      *
61      * @param targetKey the target key of the entity that asked for the action that triggered this response message
62      * @param successful the successful if the action in the triggering message worked
63      * @param messageData the message data which may indicate specific conditions for the response
64      * @param responseTo the message to which this message is a response
65      */
66     public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful, final String messageData,
67             final Message responseTo) {
68         super(targetKey, successful, messageData, responseTo);
69     }
70
71     /**
72      * Gets the engine service key.
73      *
74      * @return the engine service key
75      */
76     public AxArtifactKey getEngineServiceKey() {
77         return engineServiceKey;
78     }
79
80     /**
81      * Sets the engine service key.
82      *
83      * @param engineServiceKey the engine service key
84      */
85     public void setEngineServiceKey(final AxArtifactKey engineServiceKey) {
86         this.engineServiceKey = engineServiceKey;
87     }
88
89     /**
90      * Gets the engine key array.
91      *
92      * @return the engine key array
93      */
94     public AxArtifactKey[] getEngineKeyArray() {
95         return engineKeyArray;
96     }
97
98     /**
99      * Sets the engine key array.
100      *
101      * @param engineKeyCollection the engine key array
102      */
103     public void setEngineKeyArray(final Collection<AxArtifactKey> engineKeyCollection) {
104         if (engineKeyCollection != null) {
105             engineKeyArray = engineKeyCollection.toArray(new AxArtifactKey[engineKeyCollection.size()]);
106         } else {
107             engineKeyArray = null;
108         }
109     }
110
111     /**
112      * Gets the apex model key.
113      *
114      * @return the apex model key
115      */
116     public AxArtifactKey getApexModelKey() {
117         return apexModelKey;
118     }
119
120     /**
121      * Sets the apex model key.
122      *
123      * @param apexModelKey the apex model key
124      */
125     public void setApexModelKey(final AxArtifactKey apexModelKey) {
126         this.apexModelKey = apexModelKey;
127     }
128
129     /**
130      * {@inheritDoc}.
131      */
132     @Override
133     public int hashCode() {
134         final int prime = 31;
135         int result = super.hashCode();
136         result = prime * result + ((apexModelKey == null) ? 0 : apexModelKey.hashCode());
137         result = prime * result + Arrays.hashCode(engineKeyArray);
138         result = prime * result + ((engineServiceKey == null) ? 0 : engineServiceKey.hashCode());
139         return result;
140     }
141
142     /**
143      * {@inheritDoc}.
144      */
145     @Override
146     public boolean equals(Object obj) {
147         if (this == obj) {
148             return true;
149         }
150         if (!super.equals(obj)) {
151             return false;
152         }
153
154         EngineServiceInfoResponse other = (EngineServiceInfoResponse) obj;
155         if (apexModelKey == null) {
156             if (other.apexModelKey != null) {
157                 return false;
158             }
159         } else if (!apexModelKey.equals(other.apexModelKey)) {
160             return false;
161         }
162         if (!Arrays.equals(engineKeyArray, other.engineKeyArray)) {
163             return false;
164         }
165         if (engineServiceKey == null) {
166             if (other.engineServiceKey != null) {
167                 return false;
168             }
169         } else if (!engineServiceKey.equals(other.engineServiceKey)) {
170             return false;
171         }
172         return true;
173     }
174 }