summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin/src/test/java/com/yahoo/feedhandler/v3/NullFeedMetric.java
blob: 4777c6c7b998e333f30f2d8e5bb776809e4c3e46 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.feedhandler.v3;

import com.yahoo.jdisc.Metric;
import java.util.Map;

/**
 * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
 * @since 5.1.20
 */
public final class NullFeedMetric implements Metric {

    public NullFeedMetric(boolean flag) {
        if (!flag) {
            throw new IllegalArgumentException("must set flag allowing to throw away metrics");
        }
    }

    @Override
    public void set(String key, Number val, Context ctx) {
    }

    @Override
    public void add(String key, Number val, Context ctx) {
    }

    @Override
    public Context createContext(Map<String, ?> properties) {
        return NullFeedContext.INSTANCE;
    }

    private static class NullFeedContext implements Context {
        private static final NullFeedContext INSTANCE = new NullFeedContext();
    }
}