blob: af84bbbb5bd46013e4fbbca942c55f34ee121c11 (
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
|
package com.yahoo.schema.parser;
import com.yahoo.schema.document.Sorting.Function;
import com.yahoo.schema.document.Sorting.Strength;
import java.util.Optional;
/**
* This class holds the extracted information after parsing a "sorting"
* block, using simple data structures as far as possible. Do not put
* advanced logic here!
* @author arnej27959
**/
class ParsedSorting extends ParsedBlock {
private boolean ascending = true;
private Function sortFunction = null;
private Strength sortStrength = null;
private String sortLocale = null;
ParsedSorting(String blockName, String blockType) {
super(blockName, blockType);
}
boolean getAscending() { return this.ascending; }
boolean getDescending() { return ! this.ascending; }
Optional<Function> getFunction() { return Optional.ofNullable(sortFunction); }
Optional<Strength> getStrength() { return Optional.ofNullable(sortStrength); }
Optional<String> getLocale() { return Optional.ofNullable(sortLocale); }
void setAscending() { this.ascending = true; }
void setDescending() { this.ascending = false; }
void setLocale(String value) {
verifyThat(sortLocale == null, "sorting already has locale", sortLocale);
this.sortLocale = value;
}
void setFunction(Function value) {
verifyThat(sortFunction == null, "sorting already has function", sortFunction);
this.sortFunction = value;
}
void setStrength(Strength value) {
verifyThat(sortStrength == null, "sorting already has strength", sortStrength);
this.sortStrength = value;
}
}
|