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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.core.protocols.engdep.messages;
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;
29 * The Class Response is a message that holds the response by an Apex engine to another Actino message sent to that
32 * @author Liam Fallon (liam.fallon@ericsson.com)
34 public class EngineServiceInfoResponse extends Response {
35 private static final long serialVersionUID = -7895025789667402067L;
37 // The engine service key
38 private AxArtifactKey engineServiceKey;
40 // The engines under the control of this engine service
41 private AxArtifactKey[] engineKeyArray;
43 // The engine service key
44 private AxArtifactKey apexModelKey;
47 * Instantiates a new EngineServiceInfoResponse message.
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
53 public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful,
54 final Message responseTo) {
55 super(targetKey, successful, null, responseTo);
59 * Instantiates a new EngineServiceInfoResponse message.
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
66 public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful, final String messageData,
67 final Message responseTo) {
68 super(targetKey, successful, messageData, responseTo);
72 * Gets the engine service key.
74 * @return the engine service key
76 public AxArtifactKey getEngineServiceKey() {
77 return engineServiceKey;
81 * Sets the engine service key.
83 * @param engineServiceKey the engine service key
85 public void setEngineServiceKey(final AxArtifactKey engineServiceKey) {
86 this.engineServiceKey = engineServiceKey;
90 * Gets the engine key array.
92 * @return the engine key array
94 public AxArtifactKey[] getEngineKeyArray() {
95 return engineKeyArray;
99 * Sets the engine key array.
101 * @param engineKeyCollection the engine key array
103 public void setEngineKeyArray(final Collection<AxArtifactKey> engineKeyCollection) {
104 if (engineKeyCollection != null) {
105 engineKeyArray = engineKeyCollection.toArray(new AxArtifactKey[engineKeyCollection.size()]);
107 engineKeyArray = null;
112 * Gets the apex model key.
114 * @return the apex model key
116 public AxArtifactKey getApexModelKey() {
121 * Sets the apex model key.
123 * @param apexModelKey the apex model key
125 public void setApexModelKey(final AxArtifactKey apexModelKey) {
126 this.apexModelKey = apexModelKey;
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());
146 public boolean equals(Object obj) {
150 if (!super.equals(obj)) {
154 EngineServiceInfoResponse other = (EngineServiceInfoResponse) obj;
155 if (apexModelKey == null) {
156 if (other.apexModelKey != null) {
159 } else if (!apexModelKey.equals(other.apexModelKey)) {
162 if (!Arrays.equals(engineKeyArray, other.engineKeyArray)) {
165 if (engineServiceKey == null) {
166 if (other.engineServiceKey != null) {
169 } else if (!engineServiceKey.equals(other.engineServiceKey)) {