diff options
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryTransform.java | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryTransform.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryTransform.java index e94518c988d..d1d22886642 100644 --- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryTransform.java +++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryTransform.java @@ -37,33 +37,20 @@ public enum SummaryTransform { /** Returns the bolded version of this transform if possible, throws if not */ public SummaryTransform bold() { - switch (this) { - case NONE: - case BOLDED: - return BOLDED; - - case DYNAMICBOLDED: - case DYNAMICTEASER: - return DYNAMICBOLDED; - - default: - throw new IllegalArgumentException("Can not bold a '" + this + "' field."); - } + return switch (this) { + case NONE, BOLDED -> BOLDED; + case DYNAMICBOLDED, DYNAMICTEASER -> DYNAMICBOLDED; + default -> throw new IllegalArgumentException("Can not bold a '" + this + "' field."); + }; } /** Returns the unbolded version of this transform */ public SummaryTransform unbold() { - switch (this) { - case NONE: - case BOLDED: - return NONE; - - case DYNAMICBOLDED: - return DYNAMICTEASER; - - default: - return this; - } + return switch (this) { + case NONE, BOLDED -> NONE; + case DYNAMICBOLDED -> DYNAMICTEASER; + default -> this; + }; } /** Returns whether this value is bolded */ @@ -83,23 +70,16 @@ public enum SummaryTransform { /** Returns whether this transform always gets its value by accessing memory only */ public boolean isInMemory() { - switch (this) { - case ATTRIBUTE: - case DISTANCE: - case POSITIONS: - case GEOPOS: - case RANKFEATURES: - case SUMMARYFEATURES: - case ATTRIBUTECOMBINER: - case MATCHED_ATTRIBUTE_ELEMENTS_FILTER: - return true; - - default: - return false; - } + return switch (this) { + case ATTRIBUTE, DISTANCE, POSITIONS, GEOPOS, RANKFEATURES, SUMMARYFEATURES, ATTRIBUTECOMBINER, MATCHED_ATTRIBUTE_ELEMENTS_FILTER -> + true; + default -> false; + }; } + @Override public String toString() { return name; } + } |