aboutsummaryrefslogtreecommitdiffstats
path: root/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/AggregationKey.java
blob: a8478800b68e09b32a5f643785b6be6ea008e727 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.metric;

import ai.vespa.metricsproxy.metric.model.ConsumerId;
import ai.vespa.metricsproxy.metric.model.DimensionId;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * @author gjoranv
 */
public final class AggregationKey {

    private final Map<DimensionId, String> dimensions;
    private final Set<ConsumerId> consumers;

    public AggregationKey(Map<DimensionId, String> dimensions, Set<ConsumerId> consumers) {
        this.dimensions = dimensions;
        this.consumers = consumers;
    }

    public Map<DimensionId, String> getDimensions() { return Collections.unmodifiableMap(dimensions); }

    public Set<ConsumerId> getConsumers() { return Collections.unmodifiableSet(consumers); }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AggregationKey that = (AggregationKey) o;
        return Objects.equals(dimensions, that.dimensions) &&
                Objects.equals(consumers, that.consumers);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dimensions, consumers);
    }
}