Merge "[AAI] Fix doc config files"
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / delta / ObjectDelta.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2019 AT&T Intellectual Property. 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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.aai.util.delta;
22
23 import com.google.gson.annotations.SerializedName;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import org.apache.commons.lang3.builder.ToStringBuilder;
31
32 public class ObjectDelta {
33
34     @SerializedName("uri")
35     private String uri;
36
37     @SerializedName("action")
38     private DeltaAction action;
39
40     @SerializedName("source-of-truth")
41     private String sourceOfTruth;
42
43     @SerializedName("timestamp")
44     private long timestamp;
45
46     @SerializedName("property-deltas")
47     private Map<String, PropertyDelta> propertyDeltas = new HashMap<>();
48
49     @SerializedName("relationship-deltas")
50     private List<RelationshipDelta> relationshipDeltas = new ArrayList<>();
51
52     public ObjectDelta(String uri, DeltaAction action, String sourceOfTruth, long timestamp) {
53         this.uri = uri;
54         this.action = action;
55         this.sourceOfTruth = sourceOfTruth;
56         this.timestamp = timestamp;
57     }
58
59     public void addPropertyDelta(String prop, PropertyDelta propertyDelta) {
60         propertyDeltas.put(prop, propertyDelta);
61     }
62
63     public void addRelationshipDelta(RelationshipDelta relationshipDelta) {
64         relationshipDeltas.add(relationshipDelta);
65     }
66
67     public String getUri() {
68         return uri;
69     }
70
71     public void setUri(String uri) {
72         this.uri = uri;
73     }
74
75     public DeltaAction getAction() {
76         return action;
77     }
78
79     public void setAction(DeltaAction action) {
80         this.action = action;
81     }
82
83     public String getSourceOfTruth() {
84         return sourceOfTruth;
85     }
86
87     public void setSourceOfTruth(String sourceOfTruth) {
88         this.sourceOfTruth = sourceOfTruth;
89     }
90
91     public long getTimestamp() {
92         return timestamp;
93     }
94
95     public void setTimestamp(long timestamp) {
96         this.timestamp = timestamp;
97     }
98
99     public void setPropertyDeltas(Map<String, PropertyDelta> propertyDeltas) {
100         this.propertyDeltas = propertyDeltas;
101     }
102
103     public void setRelationshipDeltas(List<RelationshipDelta> relationshipDeltas) {
104         this.relationshipDeltas = relationshipDeltas;
105     }
106
107     public Map<String, PropertyDelta> getPropertyDeltas() {
108         return propertyDeltas;
109     }
110
111     public List<RelationshipDelta> getRelationshipDeltas() {
112         return relationshipDeltas;
113     }
114
115     @Override
116     public String toString() {
117         return new ToStringBuilder(this).append("uri", uri).append("action", action)
118                 .append("sourceOfTruth", sourceOfTruth).append("timestamp", timestamp)
119                 .append("propertyDeltas", propertyDeltas).append("relationshipDeltas", relationshipDeltas).toString();
120     }
121 }