ddac9cbf3a216ab9720361ad5dbb91b30853d615
[dcaegen2/services/prh.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * PNF-REGISTRATION-HANDLER
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA 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 package org.onap.dcaegen2.services.prh.response;
21
22 import static java.util.Collections.unmodifiableList;
23
24 import java.util.Collections;
25 import java.util.List;
26 import java.util.Optional;
27 import java.util.StringJoiner;
28 import org.springframework.lang.NonNull;
29 import org.springframework.lang.Nullable;
30
31 /**
32  * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
33  */
34 public class DMaaPConsumerResponseImpl implements DMaaPConsumerResponse {
35
36
37     private final Integer responseCode;
38     private final String responseMessage;
39     private final List<String> fetchedMessage;
40
41     public DMaaPConsumerResponseImpl(@NonNull Integer responseCode, @NonNull String responseMessage,
42         @Nullable List<String> fetchedMessage) {
43         this.responseCode = responseCode;
44         this.responseMessage = responseMessage;
45         this.fetchedMessage = Optional.ofNullable(fetchedMessage).orElse(Collections.emptyList());
46     }
47
48
49     @Override
50     public String getResponseMessage() {
51         return responseMessage;
52     }
53
54     @Override
55     public Integer getResponseCode() {
56         return responseCode;
57     }
58
59     @Override
60     public List<String> getFetchedMessages() {
61         return unmodifiableList(fetchedMessage);
62     }
63
64     @Override
65     public String toString() {
66         return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]")
67             .add("responseCode=" + responseCode)
68             .add("responseMessage=" + responseMessage)
69             .add("fetchedMessage=" + fetchedMessage)
70             .toString();
71     }
72 }