aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/document/Dictionary.java
blob: 11a94c1d89979aa130f5c338c81e4a1c284f1634 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.schema.document;

/**
 * Represents settings for dictionary control
 *
 * @author baldersheim
 */
public class Dictionary {

    public enum Type { BTREE, HASH, BTREE_AND_HASH };
    private Type type = null;
    private Case casing= 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(Case casing) {
        if (this.casing != null) {
            throw new IllegalArgumentException("dictionary match mode has already been set to " + this.casing);
        }
        this.casing = casing;
    }
    public Type getType() { return (type != null) ? type : Type.BTREE; }
    public Case getMatch() { return (casing != null) ? casing : Case.UNCASED; }

}