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

/**
 * This is the abstract super class of both {@link GroupingOperation} and {@link GroupingExpression}. All nodes can be
 * assigned a {@link String} label which in turn can be used to identify the corresponding result objects.
 *
 * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
 */
public abstract class GroupingNode {

    private final String image;
    private String label = null;

    protected GroupingNode(String image) {
        this.image = image;
    }

    /**
     * Returns the label assigned to this grouping expression.
     *
     * @return The label string.
     */
    public String getLabel() {
        return label;
    }

    /**
     * Assigns a label to this grouping expression. The label is applied to the results of this expression so that they
     * can be identified by the caller when processing the output.
     *
     * @param str The label to assign to this.
     * @return This, to allow chaining.
     */
    public GroupingNode setLabel(String str) {
        label = str;
        return this;
    }

    @Override
    public String toString() {
        return image;
    }
}