aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/main/java/ai/vespa/client/dsl/Annotation.java
blob: 66887365d73b83642c9fe26c31518d1a93fa5e8d (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;

import java.util.HashMap;
import java.util.Map;

public class Annotation {

    private final Map<String, Object> annotations;

    Annotation() {
        this(new HashMap<>());
    }

    Annotation(Map<String, Object> annotations) {
        this.annotations = annotations;
    }

    public Annotation append(Annotation a) {
        this.annotations.putAll(a.annotations);
        return this;
    }

    public boolean contains(String key) {
        return annotations.containsKey(key);
    }

    public Object get(String key) {
        return annotations.get(key);
    }

    @Override
    public String toString() {
        return annotations == null || annotations.isEmpty() ? "" : Q.toJson(annotations);
    }

}