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

/**
 * This class represents a document value in a {@link GroupingExpression}. As such, the subclasses of this can only be
 * used as document-level expressions (i.e. level 0, see {@link GroupingExpression#resolveLevel(int)}).
 *
 * @author Simon Thoresen Hult
 */
public abstract class DocumentValue extends GroupingExpression {

    protected DocumentValue(String image, String label, Integer level) {
        super(image, label, level);
    }

    @Override
    public void resolveLevel(int level) {
        if (level != 0) {
            throw new IllegalArgumentException("Expression '" + this + "' not applicable for " +
                                               GroupingOperation.getLevelDesc(level) + ".");
        }
        super.resolveLevel(level);
    }

}