2 * ============LICENSE_START=======================================================
3 * org.onap.dcaegen2.collectors.ves
4 * ================================================================================
5 * Copyright (C) 2018,2021 Nokia. 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=========================================================
20 package org.onap.dcae.common.publishing;
22 import io.vavr.collection.List;
23 import io.vavr.control.Option;
25 import java.util.Objects;
28 * @author Pawel Szalapski (pawel.szalapski@nokia.com)
30 public final class PublisherConfig {
32 private final List<String> destinations;
33 private final String topic;
34 private String userName;
35 private String password;
37 PublisherConfig(List<String> destinations, String topic) {
38 this.destinations = destinations;
43 PublisherConfig(List<String> destinations, String topic, String userName, String password) {
44 this.destinations = destinations;
46 this.userName = userName;
47 this.password = password;
50 List<String> destinations() {
54 String getHostAndPort(){
55 return destinations.get(0);
62 Option<String> userName() {
63 return Option.of(userName);
66 Option<String> password() {
67 return Option.of(password);
71 return userName().isDefined() && password().isDefined();
76 public boolean equals(Object o) {
80 if (o == null || getClass() != o.getClass()) {
83 PublisherConfig that = (PublisherConfig) o;
84 return Objects.equals(destinations, that.destinations) &&
85 Objects.equals(topic, that.topic) &&
86 Objects.equals(userName, that.userName) &&
87 Objects.equals(password, that.password);
91 public int hashCode() {
92 return Objects.hash(destinations, topic, userName, password);
96 public String toString() {
97 return "PublisherConfig{" +
98 "destinations=" + destinations +
99 ", topic='" + topic + '\'' +
100 ", userName='" + userName + '\'' +
101 ", password='" + password + '\'' +