2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.util.delta;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
28 import org.apache.commons.lang3.builder.ToStringBuilder;
30 import com.google.gson.annotations.SerializedName;
32 public class ObjectDelta {
34 @SerializedName("uri")
37 @SerializedName("action")
38 private DeltaAction action;
40 @SerializedName("source-of-truth")
41 private String sourceOfTruth;
43 @SerializedName("timestamp")
44 private long timestamp;
46 @SerializedName("property-deltas")
47 private Map<String, PropertyDelta> propertyDeltas = new HashMap<>();
49 @SerializedName("relationship-deltas")
50 private List<RelationshipDelta> relationshipDeltas = new ArrayList<>();
52 public ObjectDelta(String uri, DeltaAction action, String sourceOfTruth, long timestamp) {
55 this.sourceOfTruth = sourceOfTruth;
56 this.timestamp = timestamp;
59 public void addPropertyDelta(String prop, PropertyDelta propertyDelta) {
60 propertyDeltas.put(prop, propertyDelta);
63 public void addRelationshipDelta(RelationshipDelta relationshipDelta) {
64 relationshipDeltas.add(relationshipDelta);
68 public String getUri() {
72 public void setUri(String uri) {
76 public DeltaAction getAction() {
80 public void setAction(DeltaAction action) {
84 public String getSourceOfTruth() {
88 public void setSourceOfTruth(String sourceOfTruth) {
89 this.sourceOfTruth = sourceOfTruth;
92 public long getTimestamp() {
96 public void setTimestamp(long timestamp) {
97 this.timestamp = timestamp;
100 public void setPropertyDeltas(Map<String, PropertyDelta> propertyDeltas) {
101 this.propertyDeltas = propertyDeltas;
104 public void setRelationshipDeltas(List<RelationshipDelta> relationshipDeltas) {
105 this.relationshipDeltas = relationshipDeltas;
108 public Map<String, PropertyDelta> getPropertyDeltas() {
109 return propertyDeltas;
112 public List<RelationshipDelta> getRelationshipDeltas() {
113 return relationshipDeltas;
117 public String toString() {
118 return new ToStringBuilder(this)
120 .append("action", action)
121 .append("sourceOfTruth", sourceOfTruth)
122 .append("timestamp", timestamp)
123 .append("propertyDeltas", propertyDeltas)
124 .append("relationshipDeltas", relationshipDeltas)