Update eclipse.persistence and eelf.core in aai-common
[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 import org.apache.commons.lang3.builder.ToStringBuilder;
25
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31 public class ObjectDelta {
32
33     @SerializedName("uri")
34     private String uri;
35
36     @SerializedName("action")
37     private DeltaAction action;
38
39     @SerializedName("source-of-truth")
40     private String sourceOfTruth;
41
42     @SerializedName("timestamp")
43     private long timestamp;
44
45     @SerializedName("property-deltas")
46     private Map<String, PropertyDelta> propertyDeltas = new HashMap<>();
47
48     @SerializedName("relationship-deltas")
49     private List<RelationshipDelta> relationshipDeltas = new ArrayList<>();
50
51     public ObjectDelta(String uri, DeltaAction action, String sourceOfTruth, long timestamp) {
52         this.uri = uri;
53         this.action = action;
54         this.sourceOfTruth = sourceOfTruth;
55         this.timestamp = timestamp;
56     }
57
58     public void addPropertyDelta(String prop, PropertyDelta propertyDelta) {
59         propertyDeltas.put(prop, propertyDelta);
60     }
61
62     public void addRelationshipDelta(RelationshipDelta relationshipDelta) {
63         relationshipDeltas.add(relationshipDelta);
64     }
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)
118             .append("uri", uri)
119             .append("action", action)
120             .append("sourceOfTruth", sourceOfTruth)
121             .append("timestamp", timestamp)
122             .append("propertyDeltas", propertyDeltas)
123             .append("relationshipDeltas", relationshipDeltas)
124             .toString();
125     }
126 }