Remove the apache commons-lang dependency 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 java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.apache.commons.lang3.builder.ToStringBuilder;
29
30 import com.google.gson.annotations.SerializedName;
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
68     public String getUri() {
69         return uri;
70     }
71
72     public void setUri(String uri) {
73         this.uri = uri;
74     }
75
76     public DeltaAction getAction() {
77         return action;
78     }
79
80     public void setAction(DeltaAction action) {
81         this.action = action;
82     }
83
84     public String getSourceOfTruth() {
85         return sourceOfTruth;
86     }
87
88     public void setSourceOfTruth(String sourceOfTruth) {
89         this.sourceOfTruth = sourceOfTruth;
90     }
91
92     public long getTimestamp() {
93         return timestamp;
94     }
95
96     public void setTimestamp(long timestamp) {
97         this.timestamp = timestamp;
98     }
99
100     public void setPropertyDeltas(Map<String, PropertyDelta> propertyDeltas) {
101         this.propertyDeltas = propertyDeltas;
102     }
103
104     public void setRelationshipDeltas(List<RelationshipDelta> relationshipDeltas) {
105         this.relationshipDeltas = relationshipDeltas;
106     }
107
108     public Map<String, PropertyDelta> getPropertyDeltas() {
109         return propertyDeltas;
110     }
111
112     public List<RelationshipDelta> getRelationshipDeltas() {
113         return relationshipDeltas;
114     }
115
116     @Override
117     public String toString() {
118         return new ToStringBuilder(this)
119             .append("uri", uri)
120             .append("action", action)
121             .append("sourceOfTruth", sourceOfTruth)
122             .append("timestamp", timestamp)
123             .append("propertyDeltas", propertyDeltas)
124             .append("relationshipDeltas", relationshipDeltas)
125             .toString();
126     }
127 }