aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/parser/ParsedSummaryField.java
blob: 8f9733d25951ddbad2ea0a17c9af5a9df98b8e9b (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
53
54
55
56
57
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.parser;

import java.util.ArrayList;
import java.util.List;

/**
 * This class holds the extracted information after parsing a summary
 * field declaration, either from "field" inside "document-summary" or
 * "summary" inside "field".  Using simple data structures as far as
 * possible.  Do not put advanced logic here!
 * @author arnej27959
 **/
class ParsedSummaryField extends ParsedBlock {

    private ParsedType type;
    private boolean isDyn = false;
    private boolean isMEO = false;
    private boolean isFull = false;
    private boolean isBold = false;
    private boolean isTokens = false;
    private boolean hasExplicitType = false;
    private final List<String> sources = new ArrayList<>();
    private final List<String> destinations = new ArrayList<>();

    ParsedSummaryField(String name) {
        this(name, null);
    }

    ParsedSummaryField(String name, ParsedType type) {
        super(name, "summary field");
        this.type = type;
    }

    ParsedType getType() { return type; }
    List<String> getDestinations() { return List.copyOf(destinations); }
    List<String> getSources() { return List.copyOf(sources); }
    boolean getBolded() { return isBold; }
    boolean getDynamic() { return isDyn; }
    boolean getFull() { return isFull; }
    boolean getMatchedElementsOnly() { return isMEO; }
    boolean getTokens() { return isTokens; }
    boolean getHasExplicitType() { return hasExplicitType; }

    void addDestination(String dst) { destinations.add(dst); }
    void addSource(String src) { sources.add(src); }
    void setBold(boolean value) { this.isBold = value; }
    void setDynamic() { this.isDyn = true; }
    void setFull() { this.isFull = true; }
    void setMatchedElementsOnly() { this.isMEO = true; }
    void setTokens() { this.isTokens = true; }
    void setHasExplicitType() { this.hasExplicitType = true; }
    void setType(ParsedType value) {
        verifyThat(type == null, "Cannot change type from ", type, "to", value);
        this.type = value;
    }
}