2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.openecomp.sdc.be.model;
23 import java.io.IOException;
25 import com.fasterxml.jackson.annotation.JsonProperty;
26 import com.fasterxml.jackson.core.type.TypeReference;
27 import com.fasterxml.jackson.databind.ObjectMapper;
28 import com.fasterxml.jackson.databind.SerializationFeature;
31 public class CatalogUpdateTimestamp {
35 @JsonProperty("previousUpdateTime")
36 private long previousUpdateTime;
37 @JsonProperty("currentUpdateTime")
38 private long currentUpdateTime;
40 public CatalogUpdateTimestamp() {
42 public CatalogUpdateTimestamp(long previousUpdateTime, long currentUpdateTime) {
43 this.previousUpdateTime = previousUpdateTime;
44 this.currentUpdateTime = currentUpdateTime;
47 public CatalogUpdateTimestamp(CatalogUpdateTimestamp catalogUpdateTimestamp) {
48 this.previousUpdateTime = catalogUpdateTimestamp.getPreviousUpdateTime();
49 this.currentUpdateTime = catalogUpdateTimestamp.getCurrentUpdateTime();
53 public boolean equals(Object obj) {
54 if (obj instanceof CatalogUpdateTimestamp){
55 return (this.getCurrentUpdateTime() == ((CatalogUpdateTimestamp) obj).getCurrentUpdateTime()
56 && this.getPreviousUpdateTime() == ((CatalogUpdateTimestamp) obj).getPreviousUpdateTime())
63 public long getCurrentUpdateTime() {
64 return currentUpdateTime;
68 public long getPreviousUpdateTime() {
69 return previousUpdateTime;
73 public void setPreviousUpdateTime(long previousUpdateTime) {
74 this.previousUpdateTime = previousUpdateTime;
77 public void setCurrentUpdateTime(long currentUpdateTime) {
78 this.currentUpdateTime = currentUpdateTime;
82 public int hashCode() {
83 return super.hashCode();
87 public String toString() {
88 return "CatalogUpdateTimestamp [currentUpdateTime = " + currentUpdateTime + ", previousUpdateTime = " + previousUpdateTime + "]";
91 public static CatalogUpdateTimestamp buildFromHttpResponse(String responseBody) throws IOException {
92 ObjectMapper objectMapper = new ObjectMapper();
93 objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
94 TypeReference<CatalogUpdateTimestamp> typeRef = new TypeReference<CatalogUpdateTimestamp>() {};
95 return objectMapper.readValue(responseBody, typeRef);
97 public static CatalogUpdateTimestamp buildDummyCatalogUpdateTimestamp() {
98 long currentTimeMillis = System.currentTimeMillis();
99 return new CatalogUpdateTimestamp(0L, currentTimeMillis);