diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-02-24 12:07:05 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-02-24 18:05:20 +0000 |
commit | 7fcddc25b06c60b76494e0d26a3adab20d334dbc (patch) | |
tree | 455bc927e6a7ba8b36d489d106e067cbe65a3783 /config-model/src/main/java/com/yahoo | |
parent | 7920024a2afdd2630f0f86e9deb5de6e1e46281f (diff) |
flesh out ParsedSorting
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSorting.java | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSorting.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSorting.java index 2a090e94312..d4686c594da 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSorting.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSorting.java @@ -1,23 +1,49 @@ package com.yahoo.searchdefinition.parser; +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 { +class ParsedSorting extends ParsedBlock { enum Function { RAW, LOWERCASE, UCA } enum Strength { PRIMARY, SECONDARY, TERTIARY, QUATERNARY, IDENTICAL } - void setAscending() {} - void setDescending() {} + 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 setLocale(String locale) {} + void setDescending() { this.ascending = false; } - void setFunction(Function func) {} - void setStrength(Strength strength) {} + 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; + } } |