2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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.multiplestreamreducer;
22 import io.vavr.Tuple2;
23 import io.vavr.collection.Map;
25 public class MultipleStreamReducer {
28 * Converts configuration from: "one domain many streams"
29 * to: "one domain one stream"
31 * @param map domain to streams configuration
32 * @return configuration - one domain one stream
34 public Map<String, String> reduce(Map<String, String[]> map) {
36 .toMap(Tuple2::_1, v -> v._2[0]);
40 * Information about the current match: domain to stream
42 * @param domainToStreamConfig domain to stream configuration
43 * @return current domain to stream information
45 public String getDomainToStreamsInfo(Map<String, String> domainToStreamConfig) {
46 return domainToStreamConfig.map(v -> "Domain: " +
47 v._1 + " has active stream: " + v._2 + System.lineSeparator())
48 .reduce((a, b) -> a + b);