Open Kilda Java Documentation
CacheTimeTag.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 package org.openkilda.messaging.info;
16 
17 
18 import com.fasterxml.jackson.annotation.JsonCreator;
19 import com.fasterxml.jackson.annotation.JsonInclude;
20 import com.fasterxml.jackson.annotation.JsonProperty;
21 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
22 import com.google.common.base.Objects;
23 
24 @JsonSerialize
25 @JsonInclude(JsonInclude.Include.NON_NULL)
26 public class CacheTimeTag extends InfoData {
27 
28  @JsonProperty("created_in_cache")
29  private Long createdInCache;
30 
31  @JsonProperty("updated_in_cache")
32  private Long updatedInCache;
33 
34  public CacheTimeTag() {
35  }
36 
37  @JsonCreator
38  public CacheTimeTag(@JsonProperty("created_in_cache") Long createdInCache,
39  @JsonProperty("updated_in_cache") Long updatedInCache) {
40  this.createdInCache = createdInCache;
41  this.updatedInCache = updatedInCache;
42  }
43 
44  public Long getCreatedInCache() {
45  return createdInCache;
46  }
47 
48  public void setCreatedInCache(Long created_in_cache) {
49  this.createdInCache = created_in_cache;
50  }
51 
52  public void setCreatedInCacheNow() {
53  this.createdInCache = getUnixTimestamp();
54  }
55 
56  public Long getUpdatedInCache() {
57  return updatedInCache;
58  }
59 
60  public void setUpdatedInCache(Long updated_in_cache) {
61  this.updatedInCache = updated_in_cache;
62  }
63 
64  public void setUpdatedInCacheNow() {
65  this.updatedInCache = getUnixTimestamp();
66  }
67 
68  public void copyTimeTag(CacheTimeTag src) {
69  this.createdInCache = src.createdInCache;
70  this.updatedInCache = src.updatedInCache;
71  }
72 
73  @Override
74  public boolean equals(Object o) {
75  if (this == o) {
76  return true;
77  }
78  if (!(o instanceof CacheTimeTag)) {
79  return false;
80  }
81  CacheTimeTag that = (CacheTimeTag) o;
82  return Objects.equal(createdInCache, that.createdInCache) &&
83  Objects.equal(updatedInCache, that.updatedInCache);
84  }
85 
86  @Override
87  public int hashCode() {
88  return Objects.hashCode(createdInCache, updatedInCache);
89  }
90 
91 
92  private Long getUnixTimestamp()
93  {
94  return System.currentTimeMillis() / 1000L;
95  }
96 }
void setUpdatedInCache(Long updated_in_cache)
void setCreatedInCache(Long created_in_cache)
CacheTimeTag(@JsonProperty("created_in_cache") Long createdInCache, @JsonProperty("updated_in_cache") Long updatedInCache)