aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/pagetemplates/model/Placeholder.java
blob: bd3a74c83db6eb7ef9d874c0c638019df678430e (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
52
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.model;

/**
 * A source placeholder is replaced with a list of source instances at evaluation time.
 * Source placeholders may not have any content themselves - attempting to call any setter on this
 * results in a IllegalStateException.
 *
 * @author bratseth
 */
public class Placeholder implements PageElement {

    private String id;

    private MapChoice valueContainer=null;

    /** Creates a source placeholder with an id. */
    public Placeholder(String id) {
        this.id=id;
    }

    public String getId() { return id; }

    /** Returns the element which contains the value(s) of this placeholder. Never null. */
    public MapChoice getValueContainer() { return valueContainer; }

    public void setValueContainer(MapChoice valueContainer) { this.valueContainer=valueContainer; }

    @Override
    public void freeze() {}

    /** Accepts a visitor to this structure */
    @Override
    public void accept(PageTemplateVisitor visitor) {
        visitor.visit(this);
    }

    @Override
    public String toString() {
        return "source placeholder '" + id + "'";
    }

    /**
     * This method always returns false, is a Placeholder always is mutable.
     * (freeze() is a NOOP.)
     */
    @Override
    public boolean isFrozen() {
        return false;
    }

}