aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponse.java
blob: 8c0c9860ade3ab2086798482d8712e8da5cb6842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*-
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.apex.core.protocols.engdep.messages;

import java.util.Arrays;
import java.util.Collection;
import org.onap.policy.apex.core.protocols.Message;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;

/**
 * The Class Response is a message that holds the response by an Apex engine to another Actino message sent to that
 * engine.
 *
 * @author Liam Fallon (liam.fallon@ericsson.com)
 */
public class EngineServiceInfoResponse extends Response {
    private static final long serialVersionUID = -7895025789667402067L;

    // The engine service key
    private AxArtifactKey engineServiceKey;

    // The engines under the control of this engine service
    private AxArtifactKey[] engineKeyArray;

    // The engine service key
    private AxArtifactKey apexModelKey;

    /**
     * Instantiates a new EngineServiceInfoResponse message.
     *
     * @param targetKey the target key of the entity that asked for the action that triggered this response message
     * @param successful the successful if the action in the triggering message worked
     * @param responseTo the message to which this message is a response
     */
    public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful,
            final Message responseTo) {
        super(targetKey, successful, null, responseTo);
    }

    /**
     * Instantiates a new EngineServiceInfoResponse message.
     *
     * @param targetKey the target key of the entity that asked for the action that triggered this response message
     * @param successful the successful if the action in the triggering message worked
     * @param messageData the message data which may indicate specific conditions for the response
     * @param responseTo the message to which this message is a response
     */
    public EngineServiceInfoResponse(final AxArtifactKey targetKey, final boolean successful, final String messageData,
            final Message responseTo) {
        super(targetKey, successful, messageData, responseTo);
    }

    /**
     * Gets the engine service key.
     *
     * @return the engine service key
     */
    public AxArtifactKey getEngineServiceKey() {
        return engineServiceKey;
    }

    /**
     * Sets the engine service key.
     *
     * @param engineServiceKey the engine service key
     */
    public void setEngineServiceKey(final AxArtifactKey engineServiceKey) {
        this.engineServiceKey = engineServiceKey;
    }

    /**
     * Gets the engine key array.
     *
     * @return the engine key array
     */
    public AxArtifactKey[] getEngineKeyArray() {
        return engineKeyArray;
    }

    /**
     * Sets the engine key array.
     *
     * @param engineKeyCollection the engine key array
     */
    public void setEngineKeyArray(final Collection<AxArtifactKey> engineKeyCollection) {
        if (engineKeyCollection != null) {
            engineKeyArray = engineKeyCollection.toArray(new AxArtifactKey[engineKeyCollection.size()]);
        } else {
            engineKeyArray = null;
        }
    }

    /**
     * Gets the apex model key.
     *
     * @return the apex model key
     */
    public AxArtifactKey getApexModelKey() {
        return apexModelKey;
    }

    /**
     * Sets the apex model key.
     *
     * @param apexModelKey the apex model key
     */
    public void setApexModelKey(final AxArtifactKey apexModelKey) {
        this.apexModelKey = apexModelKey;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((apexModelKey == null) ? 0 : apexModelKey.hashCode());
        result = prime * result + Arrays.hashCode(engineKeyArray);
        result = prime * result + ((engineServiceKey == null) ? 0 : engineServiceKey.hashCode());
        return result;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }

        EngineServiceInfoResponse other = (EngineServiceInfoResponse) obj;
        if (apexModelKey == null) {
            if (other.apexModelKey != null) {
                return false;
            }
        } else if (!apexModelKey.equals(other.apexModelKey)) {
            return false;
        }
        if (!Arrays.equals(engineKeyArray, other.engineKeyArray)) {
            return false;
        }
        if (engineServiceKey == null) {
            if (other.engineServiceKey != null) {
                return false;
            }
        } else if (!engineServiceKey.equals(other.engineServiceKey)) {
            return false;
        }
        return true;
    }
}