diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query')
5 files changed, 29 insertions, 33 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java index e3ab49f0e32..b58bd64209b 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfile.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile; -import com.google.common.collect.ImmutableList; import com.yahoo.component.ComponentId; import com.yahoo.component.provider.FreezableSimpleComponent; import com.yahoo.processing.IllegalInputException; @@ -420,7 +419,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable content.freeze(); - inherited= inherited==null ? ImmutableList.of() : ImmutableList.copyOf(inherited); + inherited= inherited==null ? List.of() : List.copyOf(inherited); super.freeze(); } @@ -616,8 +615,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable * be added (usually because the new value was added to the existing). */ static Object combineValues(Object newValue, Object existingValue) { - if (newValue instanceof QueryProfile) { - QueryProfile newProfile = (QueryProfile)newValue; + if (newValue instanceof QueryProfile newProfile) { if ( ! (existingValue instanceof QueryProfile)) { if ( ! isModifiable(newProfile)) { // Make the query profile reference overridable @@ -631,8 +629,7 @@ public class QueryProfile extends FreezableSimpleComponent implements Cloneable return combineProfiles(newProfile, (QueryProfile)existingValue); } else { - if (existingValue instanceof QueryProfile) { // we need to set a non-leaf value on a query profile - QueryProfile existingProfile = (QueryProfile)existingValue; + if (existingValue instanceof QueryProfile existingProfile) { // we need to set a non-leaf value on a query profile if (isModifiable(existingProfile)) { existingProfile.setValue(newValue); return null; diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java index 7fc8bfd40ab..57aa3516dfc 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariant.java @@ -1,11 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.search.query.profile.types.QueryProfileType; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * A variant of a query profile @@ -40,7 +42,7 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa public Map<String, Object> values() { if (values == null) { if (frozen) - return Collections.emptyMap(); + return Map.of(); else values = new HashMap<>(); } @@ -54,7 +56,7 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa public List<QueryProfile> inherited() { if (inherited == null) { if (frozen) - return Collections.emptyList(); + return List.of(); else inherited = new ArrayList<>(); } @@ -140,9 +142,9 @@ public class QueryProfileVariant implements Cloneable, Comparable<QueryProfileVa public void freeze() { if (frozen) return; if (inherited != null) - inherited = ImmutableList.copyOf(inherited); + inherited = List.copyOf(inherited); if (values != null) - values = ImmutableMap.copyOf(values); + values = Map.copyOf(values); frozen=true; } diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java index 845c2cfd384..1b0472c5b17 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileVariants.java @@ -1,12 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.component.provider.Freezable; import com.yahoo.search.query.profile.types.QueryProfileType; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * This class represent a set of query profiles virtually - rather @@ -54,7 +57,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { * on lookup time to influence the value returned. */ public QueryProfileVariants(String[] dimensions, QueryProfile owner) { - this(Arrays.asList(dimensions), owner); + this(List.of(dimensions), owner); } /** @@ -77,13 +80,13 @@ public class QueryProfileVariants implements Freezable, Cloneable { if (frozen) return; for (FieldValues fieldValues : fieldValuesByName.values()) fieldValues.freeze(); - fieldValuesByName = ImmutableMap.copyOf(fieldValuesByName); + fieldValuesByName = Map.copyOf(fieldValuesByName); inheritedProfiles.freeze(); Collections.sort(variants); for (QueryProfileVariant variant : variants) variant.freeze(); - variants = ImmutableList.copyOf(variants); + variants = List.copyOf(variants); frozen=true; } @@ -331,7 +334,7 @@ public class QueryProfileVariants implements Freezable, Cloneable { if (frozen) return; sort(); if (resolutionList != null) - resolutionList = ImmutableList.copyOf(resolutionList); + resolutionList = List.copyOf(resolutionList); frozen = true; } diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java index f30a3cc5ae6..8fdbf8b2281 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java @@ -1,11 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile.types; -import com.google.common.collect.ImmutableList; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.query.profile.QueryProfile; -import java.util.Arrays; import java.util.List; /** @@ -96,14 +94,14 @@ public class FieldDescription implements Comparable<FieldDescription> { if (name.isCompound() && ! aliases.isEmpty()) throw new IllegalArgumentException("Aliases are not allowed with compound names"); - this.aliases = ImmutableList.copyOf(aliases); + this.aliases = List.copyOf(aliases); this.mandatory = mandatory; this.overridable = overridable; } private static List<String> toList(String string) { - if (string == null || string.isEmpty()) return ImmutableList.of(); - return ImmutableList.copyOf(Arrays.asList(string.split(" "))); + if (string == null || string.isEmpty()) return List.of(); + return List.of(string.split(" ")); } /** Returns the full name of this as a string */ diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java index 02a4199d32e..3da2ad53f9a 100644 --- a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java +++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java @@ -1,12 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.query.profile.types; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.component.ComponentId; import com.yahoo.component.provider.FreezableSimpleComponent; import com.yahoo.processing.request.CompoundName; -import com.yahoo.search.query.profile.OverridableQueryProfile; import com.yahoo.search.query.profile.QueryProfile; import java.util.ArrayList; @@ -83,8 +80,7 @@ public class QueryProfileType extends FreezableSimpleComponent { Map<String, FieldDescription> unfrozenFields = new LinkedHashMap<>(); for (Map.Entry<String, FieldDescription> field : fields.entrySet()) { FieldDescription unfrozenFieldValue = field.getValue(); - if (field.getValue().getType() instanceof QueryProfileFieldType) { - QueryProfileFieldType queryProfileFieldType = (QueryProfileFieldType)field.getValue().getType(); + if (field.getValue().getType() instanceof QueryProfileFieldType queryProfileFieldType) { if (queryProfileFieldType.getQueryProfileType() != null) { QueryProfileFieldType unfrozenType = new QueryProfileFieldType(queryProfileFieldType.getQueryProfileType().unfrozen()); @@ -185,8 +181,8 @@ public class QueryProfileType extends FreezableSimpleComponent { fields.put(field.getName(), field); } } - fields = ImmutableMap.copyOf(fields); - inherited = ImmutableList.copyOf(inherited); + fields = Collections.unmodifiableMap(fields); + inherited = List.copyOf(inherited); strict = isStrict(); matchAsPath = getMatchAsPath(); super.freeze(); @@ -382,7 +378,7 @@ public class QueryProfileType extends FreezableSimpleComponent { */ public Map<String, String> aliases() { if (isFrozen()) return aliases; - if (aliases == null) return Collections.emptyMap(); + if (aliases == null) return Map.of(); return Collections.unmodifiableMap(aliases); } |