2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 TechMahindra Ltd.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.spi.model;
23 import java.io.Serializable;
25 import lombok.extern.slf4j.Slf4j;
28 public class DeltaReportBuilder {
31 private String action;
33 private Map<String, Serializable> sourceData;
34 private Map<String, Serializable> targetData;
36 public DeltaReportBuilder withXpath(final String xpath) {
41 public DeltaReportBuilder withSourceData(final Map<String, Serializable> sourceData) {
42 this.sourceData = sourceData;
46 public DeltaReportBuilder withTargetData(final Map<String, Serializable> targetData) {
47 this.targetData = targetData;
51 public DeltaReportBuilder actionAdd() {
52 this.action = DeltaReport.ADD_ACTION;
56 public DeltaReportBuilder actionRemove() {
57 this.action = DeltaReport.REMOVE_ACTION;
62 * To create a single entry of {@link DeltaReport}.
64 * @return {@link DeltaReport}
66 public DeltaReport build() {
67 final DeltaReport deltaReport = new DeltaReport();
68 deltaReport.setAction(action);
69 deltaReport.setXpath(xpath);
70 if (sourceData != null && !sourceData.isEmpty()) {
71 deltaReport.setSourceData(sourceData);
74 if (targetData != null && !targetData.isEmpty()) {
75 deltaReport.setTargetData(targetData);