2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.policy.sim.vfw;
23 import java.io.Serializable;
24 import java.util.UUID;
26 import org.openecomp.policy.appc.CommonHeader;
27 import org.openecomp.policy.appc.Response;
28 import org.openecomp.policy.appc.ResponseStatus;
30 public class AppcResponseEvent implements Serializable {
32 private static final long serialVersionUID = 6661836261200950007L;
34 public final String requestID;
35 public final String appcTopic;
36 public final int code;
38 public AppcResponseEvent(String requestID, String appcTopic, int code) {
39 this.requestID = requestID;
40 this.appcTopic = appcTopic;
45 public int hashCode() {
48 result = prime * result + ((appcTopic == null) ? 0 : appcTopic.hashCode());
49 result = prime * result + code;
50 result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
55 public boolean equals(Object obj) {
60 if (getClass() != obj.getClass())
62 AppcResponseEvent other = (AppcResponseEvent) obj;
63 if (appcTopic == null) {
64 if (other.appcTopic != null)
66 } else if (!appcTopic.equals(other.appcTopic))
68 if (code != other.code)
70 if (requestID == null) {
71 if (other.requestID != null)
73 } else if (!requestID.equals(other.requestID))
79 public String toString() {
80 return "AppcResponseEvent [requestID=" + requestID + ", appcTopic=" + appcTopic + ", code=" + code + "]";
83 public static Response toResponse(String requestId, int code) {
84 Response response = new Response();
86 CommonHeader commonHeader = new CommonHeader();
87 commonHeader.RequestID = UUID.fromString(requestId);
88 response.CommonHeader = commonHeader;
90 ResponseStatus responseStatus = new ResponseStatus();
91 responseStatus.Code = responseStatus.Code = code;
92 response.Status = responseStatus;