Use PollingConditions to improve intermittent test failure
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / model / DeltaReportBuilder.java
1 /*
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
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.spi.model;
22
23 import java.io.Serializable;
24 import java.util.Map;
25 import lombok.extern.slf4j.Slf4j;
26
27 @Slf4j
28 public class DeltaReportBuilder {
29
30
31     private String action;
32     private String xpath;
33     private Map<String, Serializable> sourceData;
34     private Map<String, Serializable> targetData;
35
36     public DeltaReportBuilder withXpath(final String xpath) {
37         this.xpath = xpath;
38         return this;
39     }
40
41     public DeltaReportBuilder withSourceData(final Map<String, Serializable> sourceData) {
42         this.sourceData = sourceData;
43         return this;
44     }
45
46     public DeltaReportBuilder withTargetData(final Map<String, Serializable> targetData) {
47         this.targetData = targetData;
48         return this;
49     }
50
51     public DeltaReportBuilder actionAdd() {
52         this.action = DeltaReport.ADD_ACTION;
53         return this;
54     }
55
56     public DeltaReportBuilder actionRemove() {
57         this.action = DeltaReport.REMOVE_ACTION;
58         return this;
59     }
60
61     /**
62      * To create a single entry of {@link DeltaReport}.
63      *
64      * @return {@link DeltaReport}
65      */
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);
72         }
73
74         if (targetData != null && !targetData.isEmpty()) {
75             deltaReport.setTargetData(targetData);
76         }
77         return deltaReport;
78     }
79 }