blob: 586622100fb1312691f5df42b8ce8ba17aab09fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.dockerapi.metrics;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Each metric reported to secret agent has dimensions.
*
* @author valerijf
*/
public class Dimensions {
final Map<String, Object> dimensionsMap;
private Dimensions(Map<String, Object> dimensionsMap) {
this.dimensionsMap = dimensionsMap;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Dimensions that = (Dimensions) o;
return dimensionsMap.equals(that.dimensionsMap);
}
@Override
public int hashCode() {
return dimensionsMap.hashCode();
}
@Override
public String toString() {
return dimensionsMap.toString();
}
public static class Builder {
private final Map<String, String> dimensionsMap = new HashMap<>();
public Dimensions.Builder add(String dimensionName, String dimensionValue) {
dimensionsMap.put(dimensionName, dimensionValue);
return this;
}
public Dimensions build() {
return new Dimensions(Collections.unmodifiableMap(new HashMap<>(dimensionsMap)));
}
}
}
|