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;
24 import org.apache.commons.lang3.builder.ToStringBuilder;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
31 public class ObjectDelta {
33 @SerializedName("uri")
36 @SerializedName("action")
37 private DeltaAction action;
39 @SerializedName("source-of-truth")
40 private String sourceOfTruth;
42 @SerializedName("timestamp")
43 private long timestamp;
45 @SerializedName("property-deltas")
46 private Map<String, PropertyDelta> propertyDeltas = new HashMap<>();
48 @SerializedName("relationship-deltas")
49 private List<RelationshipDelta> relationshipDeltas = new ArrayList<>();
51 public ObjectDelta(String uri, DeltaAction action, String sourceOfTruth, long timestamp) {
54 this.sourceOfTruth = sourceOfTruth;
55 this.timestamp = timestamp;
58 public void addPropertyDelta(String prop, PropertyDelta propertyDelta) {
59 propertyDeltas.put(prop, propertyDelta);
62 public void addRelationshipDelta(RelationshipDelta relationshipDelta) {
63 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)
119 .append("action", action)
120 .append("sourceOfTruth", sourceOfTruth)
121 .append("timestamp", timestamp)
122 .append("propertyDeltas", propertyDeltas)
123 .append("relationshipDeltas", relationshipDeltas)