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 com.google.gson.annotations.SerializedName;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
30 import org.apache.commons.lang3.builder.ToStringBuilder;
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);
67 public String getUri() {
71 public void setUri(String uri) {
75 public DeltaAction getAction() {
79 public void setAction(DeltaAction action) {
83 public String getSourceOfTruth() {
87 public void setSourceOfTruth(String sourceOfTruth) {
88 this.sourceOfTruth = sourceOfTruth;
91 public long getTimestamp() {
95 public void setTimestamp(long timestamp) {
96 this.timestamp = timestamp;
99 public void setPropertyDeltas(Map<String, PropertyDelta> propertyDeltas) {
100 this.propertyDeltas = propertyDeltas;
103 public void setRelationshipDeltas(List<RelationshipDelta> relationshipDeltas) {
104 this.relationshipDeltas = relationshipDeltas;
107 public Map<String, PropertyDelta> getPropertyDeltas() {
108 return propertyDeltas;
111 public List<RelationshipDelta> getRelationshipDeltas() {
112 return relationshipDeltas;
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();