summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/document/Dictionary.java
blob: 8f22b344e44ad728bc0b7e79db51c8b50342f6a1 (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
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.searchdefinition.document;

/**
 * Represents settings for dictionary control
 *
 * @author baldersheim
 */
public class Dictionary {
    public enum Type { BTREE, HASH, BTREE_AND_HASH };
    public enum Match { CASED, UNCASED };
    private Type type = null;
    private Match match = null;

    public void updateType(Type type) {
        if (this.type == null) {
            this.type = type;
        } else if ((this.type == Type.BTREE) && (type == Type.HASH)) {
            this.type = Type.BTREE_AND_HASH;
        } else if ((this.type == Type.HASH) && (type == Type.BTREE)) {
            this.type = Type.BTREE_AND_HASH;
        } else {
            throw new IllegalArgumentException("Can not combine previous dictionary setting " + this.type +
                    " with current " + type);
        }
    }
    public void updateMatch(Match match) {
        if (this.match != null) {
            throw new IllegalArgumentException("dictionary match mode has already been set to " + this.match);
        }
        this.match = match;
    }
    public Type getType() { return (type != null) ? type : Type.BTREE; }
    public Match getMatch() { return (match != null) ? match : Match.UNCASED; }
}