blob: 4576b7a34fe60d278e074be78deaae6875f97f48 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.fieldoperation;
import com.yahoo.document.DataType;
import com.yahoo.schema.document.SDField;
import com.yahoo.vespa.documentmodel.SummaryField;
import java.util.Iterator;
import java.util.Set;
/**
* @author Einar M R Rosenvinge
*/
public class SummaryInFieldLongOperation extends SummaryInFieldOperation {
private DataType type;
private Boolean bold;
private Set<String> destinations = new java.util.LinkedHashSet<>();
public SummaryInFieldLongOperation(String name) {
super(name);
}
public SummaryInFieldLongOperation() {
super(null);
}
public void setType(DataType type) {
this.type = type;
}
public void setBold(Boolean bold) {
this.bold = bold;
}
public void addDestination(String destination) {
destinations.add(destination);
}
public Iterator<String> destinationIterator() {
return destinations.iterator();
}
public void apply(SDField field) {
if (type == null) {
type = field.getDataType();
}
SummaryField summary = new SummaryField(name, type);
applyToSummary(summary);
field.addSummaryField(summary);
}
public void applyToSummary(SummaryField summary) {
if (transform != null) {
summary.setTransform(transform);
}
if (bold != null) {
summary.setTransform(bold ? summary.getTransform().bold() : summary.getTransform().unbold());
}
for (SummaryField.Source source : sources) {
summary.addSource(source);
}
for (String destination : destinations) {
summary.addDestination(destination);
}
}
}
|