blob: 5b3ce7136d59b3aeca66020f4687b48b6ad8ba9b (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
import com.yahoo.tensor.TensorType;
/**
* Represents a global ranking constant (declared in a .sd file)
*
* @author arnej
*/
public class RankingConstant {
/** The search definition-unique name of this constant */
private final String name;
private TensorType tensorType = null;
private String fileName = null;
private String fileRef = "";
public RankingConstant(String name) {
this.name = name;
}
public void setFileName(String fileName) { this.fileName = fileName; }
public void setFileReference(String fileRef) { this.fileRef = fileRef; }
public void setType(TensorType tensorType) { this.tensorType = tensorType; }
public String getName() { return name; }
public String getFileName() { return fileName; }
public String getFileReference() { return fileRef; }
public TensorType getTensorType() { return tensorType; }
public String getType() { return tensorType.toString(); }
public void validate() {
if (fileName == null || fileName.isEmpty())
throw new IllegalArgumentException("Ranking constants must have a file.");
if (tensorType == null)
throw new IllegalArgumentException("Ranking constant '" + name + "' must have a type.");
}
public String toString() {
StringBuilder b = new StringBuilder();
b.append("constant '").append(name)
.append("' from file '").append(fileName)
.append("' with ref '").append(fileRef)
.append("' of type '").append(tensorType)
.append("'");
return b.toString();
}
}
|