Open Kilda Java Documentation
Datapoint.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 
16 package org.openkilda.messaging.info;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 
20 import com.fasterxml.jackson.annotation.JsonCreator;
21 import com.fasterxml.jackson.annotation.JsonInclude;
22 import com.fasterxml.jackson.annotation.JsonProperty;
23 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
24 
25 import java.util.Map;
26 import java.util.Objects;
27 
28 @JsonSerialize
29 @JsonInclude(JsonInclude.Include.NON_NULL)
30 public class Datapoint extends InfoData {
31 
35  @JsonProperty("metric")
36  private String metric;
37 
41  @JsonProperty("time")
42  private Long time;
43 
47  @JsonProperty("tags")
48  private Map<String, String> tags;
49 
53  @JsonProperty("value")
54  private Number value;
55 
56  public Datapoint() {
57  }
58 
59  @JsonCreator
60  public Datapoint(@JsonProperty("metric") String metric,
61  @JsonProperty("time") Long time,
62  @JsonProperty("tags") Map<String, String> tags,
63  @JsonProperty("value") Number value) {
64  this.metric = metric;
65  this.time = time;
66  this.tags = tags;
67  this.value = value;
68  }
69 
70  public String getMetric() {
71  return metric;
72  }
73 
74  public void setMetric(String metric) {
75  this.metric = metric;
76  }
77 
78  public Long getTime() {
79  return time;
80  }
81 
82  public void setTime(Long time) {
83  this.time = time;
84  }
85 
86  public Map<String, String> getTags() {
87  return tags;
88  }
89 
90  public void setTags(Map<String, String> tags) {
91  this.tags = tags;
92  }
93 
94  public Number getValue() {
95  return value;
96  }
97 
98  public void setValue(Number value) {
99  this.value = value;
100  }
101 
102  @Override
103  public boolean equals(Object o) {
104  if (this == o) {
105  return true;
106  }
107  if (o == null || getClass() != o.getClass()) {
108  return false;
109  }
110 
111  Datapoint datapoint = (Datapoint) o;
112  return Objects.equals(metric, datapoint.getMetric())
113  && Objects.equals(tags, datapoint.getTags())
114  && Objects.equals(value, datapoint.getValue());
115  }
116 
117  @Override
118  public int hashCode() {
119  int result = metric != null ? metric.hashCode() : 0;
120  result = 31 * result + (tags != null ? tags.hashCode() : 0);
121  result = 31 * result + (value != null ? value.hashCode() : 0);
122  return result;
123  }
124 
125  public int simpleHashCode() {
126  int result = metric != null ? metric.hashCode() : 0;
127  result = 31 * result + (tags != null ? tags.hashCode() : 0);
128  return result;
129  }
130 
131  @Override
132  public String toString() {
133  return toStringHelper(this)
134  .add("metric", metric)
135  .add("time", time)
136  .add("tags", tags)
137  .add("value", value)
138  .toString();
139  }
140 }
void setTags(Map< String, String > tags)
Definition: Datapoint.java:90
value
Definition: nodes.py:62
Map< String, String > getTags()
Definition: Datapoint.java:86
list result
Definition: plan-d.py:72
Datapoint(@JsonProperty("metric") String metric, @JsonProperty("time") Long time, @JsonProperty("tags") Map< String, String > tags, @JsonProperty("value") Number value)
Definition: Datapoint.java:60