diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-05-19 12:03:06 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-05-19 12:03:06 +0200 |
commit | 5c24dc5c9642a8d9ed70aee4c950fd0678a1ebec (patch) | |
tree | bd9b74bf00c832456f0b83c1b2cd7010be387d68 /config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java | |
parent | f17c4fe7de4c55f5c4ee61897eab8c2f588d8405 (diff) |
Rename the 'searchdefinition' package to 'schema'
Diffstat (limited to 'config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java b/config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java new file mode 100644 index 00000000000..af84bbbb5bd --- /dev/null +++ b/config-model/src/main/java/com/yahoo/schema/parser/ParsedSorting.java @@ -0,0 +1,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; + } +} |