aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/hitfield/ImmutableFieldPart.java
blob: d9639ef60c74c63e1368ce66487ccb5fea81bbf8 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.hitfield;

/**
 * Represents an element of a hit property which is an immutable string element
 *
 * @author Steinar Knutsen
 */
public class ImmutableFieldPart implements FieldPart {

    private final String content;
    private final String initContent;
    // Whether this element represents a (part of) a token or a
    // delimiter string. When splitting existing parts, the new
    // parts should inherit this state from the object they were
    // split from.
    private boolean tokenOrDelimiter;

    public ImmutableFieldPart(String initContent,
                              boolean tokenOrDelimiter) {
        this(initContent, initContent, tokenOrDelimiter);
    }

    public ImmutableFieldPart(String initContent,
                              String content,
                              boolean tokenOrDelimiter) {

        this.initContent = initContent;
        this.content = content;
        this.tokenOrDelimiter = tokenOrDelimiter;
    }

    @Override
    public boolean isFinal() { return true; }
    @Override
    public boolean isToken() { return tokenOrDelimiter; }
    @Override
    public String getContent() { return content; }

    public String getInitContent() { return initContent; }

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

}