aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/templates/MapContext.java
blob: 49c5ffa6e787c0abc85cc69520f03074a8169d99 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.templates;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/** A context having a map as secondary storage */
public class MapContext extends Context {

    private Map<String, Object> map = new LinkedHashMap<>();

    @Override
    public Object get(String key) {
        return normalizeValue(map.get(key));
    }

    public Object put(String name, Object value) {
        return map.put(name, value);
    }

    public Object remove(Object name) {
        return map.remove(name);
    }

    @Override
    public Collection<? extends Object> getKeys() {
        return map.keySet();
    }

}