Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-dmaap / src / main / java / org / openecomp / dcae / apod / analytics / dmaap / domain / response / DMaaPMRSubscriberResponseImpl.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 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
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
21 package org.openecomp.dcae.apod.analytics.dmaap.domain.response;
22
23 import com.google.common.base.Objects;
24 import com.google.common.collect.ImmutableList;
25
26 import java.util.List;
27
28 import javax.annotation.Nonnull;
29 import javax.annotation.Nullable;
30
31 import static java.util.Collections.unmodifiableList;
32
33 /**
34  * <p>
35  *      A simple implementation for {@link DMaaPMRSubscriberResponse}
36  * <p>
37  * @author Rajiv Singla . Creation Date: 10/13/2016.
38  */
39 public class DMaaPMRSubscriberResponseImpl implements DMaaPMRSubscriberResponse {
40
41     private final Integer responseCode;
42     private final String responseMessage;
43     private final List<String> fetchedMessages;
44
45     public DMaaPMRSubscriberResponseImpl(@Nonnull Integer responseCode,
46                                          @Nonnull String responseMessage,
47                                          @Nullable List<String> fetchedMessages) {
48         this.responseCode = responseCode;
49         this.responseMessage = responseMessage;
50         this.fetchedMessages = fetchedMessages != null ? fetchedMessages : ImmutableList.<String>of();
51     }
52
53     public DMaaPMRSubscriberResponseImpl(Integer responseCode, String responseMessage) {
54         this(responseCode, responseMessage, null);
55     }
56
57     @Override
58     public Integer getResponseCode() {
59         return responseCode;
60     }
61
62     @Override
63     public String getResponseMessage() {
64         return responseMessage;
65     }
66
67     @Override
68     public List<String> getFetchedMessages() {
69         return unmodifiableList(fetchedMessages);
70     }
71
72     @Override
73     public String toString() {
74         return Objects.toStringHelper(this)
75                 .add("responseCode", responseCode)
76                 .add("responseMessage", responseMessage)
77                 .add("fetchedMessages(size)", fetchedMessages.size())
78                 .toString();
79     }
80 }