blob: cae9b20b7b5d87af3e0298802b6a90ebf842e788 (
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 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.document;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
/**
* The rank type of a field. For now this is just a container of a string name.
* This class is immutable.
*
* @author bratseth
*/
public enum RankType {
/** *implicit* default: No type has been set. */
DEFAULT,
// Rank types which can be set explicitly. These are defined for Vespa in NativeRankTypeDefinitionSet
IDENTITY, ABOUT, TAGS, EMPTY;
@Override
public String toString() {
return "rank type " + name().toLowerCase();
}
/**
* Returns the rank type from a string, regardless of its case.
*
* @param rankTypeName a rank type name in any casing
* @return the rank type found
* @throws IllegalArgumentException if not found
*/
public static RankType fromString(String rankTypeName) {
try {
return RankType.valueOf(rankTypeName.toUpperCase());
}
catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unknown rank type '" + rankTypeName + "'. Supported rank types are " +
"'identity', 'about', 'tags' and 'empty'.");
}
}
}
|