2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * Modifications copyright (c) 2019 AT&T
21 * ===================================================================
25 package org.onap.clamp.clds.util.drawing;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.Objects;
31 import org.onap.clamp.clds.sdc.controller.installer.MicroService;
33 public class ClampGraphBuilder {
34 private String policy;
35 private String collector;
36 private List<MicroService> microServices = new ArrayList<>();
37 private final Painter painter;
39 public ClampGraphBuilder(Painter painter) {
40 this.painter = painter;
43 public ClampGraphBuilder collector(String collector) {
44 this.collector = collector;
48 public ClampGraphBuilder policy(String policy) {
53 public ClampGraphBuilder addMicroService(MicroService ms) {
54 microServices.add(ms);
58 public ClampGraphBuilder addAllMicroServices(List<MicroService> msList) {
59 microServices.addAll(msList);
63 public ClampGraph build() {
64 if (microServices.isEmpty()) {
65 throw new InvalidStateException("At least one microservice is required");
67 if (Objects.isNull(policy) || policy.trim().isEmpty()) {
68 throw new InvalidStateException("Policy element must be present");
70 return new ClampGraph(painter.doPaint(collector, microServices, policy));