diff options
Diffstat (limited to 'config-model/src/main')
29 files changed, 60 insertions, 86 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRegistry.java b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRegistry.java index 51bd01de5bc..f25f130eed0 100644 --- a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRegistry.java +++ b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRegistry.java @@ -5,7 +5,7 @@ import com.yahoo.config.model.builder.xml.ConfigModelBuilder; import com.yahoo.config.model.builder.xml.ConfigModelId; import java.util.Collection; -import java.util.Collections; +import java.util.List; /** * A resolver of implementations of named config models. @@ -44,7 +44,7 @@ public abstract class ConfigModelRegistry { @Override public Collection<ConfigModelBuilder> resolve(ConfigModelId id) { - return Collections.emptyList(); + return List.of(); } } diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java index f19341098f4..57a75bd8a38 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java @@ -50,7 +50,6 @@ import java.io.Reader; import java.io.UncheckedIOException; import java.time.Instant; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -329,7 +328,7 @@ public class DeployState implements ConfigDefinitionStore { private Optional<ConfigDefinitionRepo> configDefinitionRepo = Optional.empty(); private Optional<Model> previousModel = Optional.empty(); private Set<ContainerEndpoint> endpoints = Set.of(); - private Collection<MlModelImporter> modelImporters = Collections.emptyList(); + private Collection<MlModelImporter> modelImporters = List.of(); private Zone zone = Zone.defaultZone(); private Instant now = Instant.now(); private Version wantedNodeVespaVersion = Vtag.currentVersion; diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index 11d3a48ee51..3e91b8afe88 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -19,7 +19,6 @@ import com.yahoo.vespa.model.container.ApplicationContainerCluster; import java.net.URI; import java.security.cert.X509Certificate; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Set; @@ -35,10 +34,10 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea private boolean multitenant = false; private ApplicationId applicationId = ApplicationId.defaultId(); - private List<ConfigServerSpec> configServerSpecs = Collections.emptyList(); + private List<ConfigServerSpec> configServerSpecs = List.of(); private boolean hostedVespa = false; private Zone zone = Zone.defaultZone(); - private final Set<ContainerEndpoint> endpoints = Collections.emptySet(); + private final Set<ContainerEndpoint> endpoints = Set.of(); private boolean useDedicatedNodeForLogserver = false; private double defaultTermwiseLimit = 1.0; private String jvmGCOptions = null; @@ -55,10 +54,10 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea private double feedConcurrency = 0.5; private double feedNiceness = 0.0; private int maxActivationInhibitedOutOfSyncGroups = 0; - private List<TenantSecretStore> tenantSecretStores = Collections.emptyList(); + private List<TenantSecretStore> tenantSecretStores = List.of(); private String jvmOmitStackTraceInFastThrowOption; private boolean allowDisableMtls = true; - private List<X509Certificate> operatorCertificates = Collections.emptyList(); + private List<X509Certificate> operatorCertificates = List.of(); private double resourceLimitDisk = 0.75; private double resourceLimitMemory = 0.8; private double minNodeRatioPerGroup = 0.0; diff --git a/config-model/src/main/java/com/yahoo/config/model/graph/ModelNode.java b/config-model/src/main/java/com/yahoo/config/model/graph/ModelNode.java index e411a8e3e77..dcf1c8629a4 100644 --- a/config-model/src/main/java/com/yahoo/config/model/graph/ModelNode.java +++ b/config-model/src/main/java/com/yahoo/config/model/graph/ModelNode.java @@ -135,7 +135,7 @@ public class ModelNode<MODEL extends ConfigModel> implements ConfigModelInstance } // For collections, we don't require that dependency has been added, we just give an empty collection if (isCollection(param)) - return Collections.emptyList(); + return List.of(); throw new IllegalArgumentException("Unable to find constructor argument " + param + " for " + clazz.getName()); } diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java index 5d3db7f676a..365543a549b 100644 --- a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java +++ b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java @@ -31,7 +31,6 @@ import java.io.UncheckedIOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -143,7 +142,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public Map<ConfigDefinitionKey, UnparsedConfigDefinition> getAllExistingConfigDefs() { - return Collections.emptyMap(); + return Map.of(); } @Override @@ -203,7 +202,7 @@ public class MockApplicationPackage implements ApplicationPackage { } public List<ComponentInfo> getComponentsInfo(Version vespaVersion) { - return Collections.emptyList(); + return List.of(); } public QueryProfileRegistry getQueryProfiles() { return queryProfileRegistry; } @@ -240,7 +239,7 @@ public class MockApplicationPackage implements ApplicationPackage { private File root = new File("nonexisting"); private String hosts = null; private String services = null; - private List<String> schemas = Collections.emptyList(); + private List<String> schemas = List.of(); private Map<Path, MockApplicationFile> files = new LinkedHashMap<>(); private String schemaDir = null; private String deploymentSpec = null; @@ -277,12 +276,12 @@ public class MockApplicationPackage implements ApplicationPackage { } public Builder withSearchDefinition(String searchDefinition) { - this.schemas = Collections.singletonList(searchDefinition); + this.schemas = List.of(searchDefinition); return this; } public Builder withSchemas(List<String> searchDefinition) { - this.schemas = Collections.unmodifiableList(searchDefinition); + this.schemas = List.copyOf(searchDefinition); return this; } @@ -369,8 +368,8 @@ public class MockApplicationPackage implements ApplicationPackage { } private List<NamedReader> asNamedReaderList(String value) { - if (value == null) return Collections.emptyList(); - return Collections.singletonList(new NamedReader(extractId(value) + ".xml", new StringReader(value))); + if (value == null) return List.of(); + return List.of(new NamedReader(extractId(value) + ".xml", new StringReader(value))); } private String extractId(String xmlStringWithIdAttribute) { diff --git a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java index 77e123fefef..c5140dd6fc8 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import static java.util.Collections.emptySet; /** * @author baldersheim @@ -47,7 +46,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp private final Set<String> importedFieldNames; public NewDocumentType(Name name) { - this(name, emptySet()); + this(name, Set.of()); } public NewDocumentType(Name name, Set<Name> documentReferences, Set<String> importedFieldNames) { @@ -60,7 +59,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp } public NewDocumentType(Name name, Set<Name> documentReferences) { - this(name, documentReferences, emptySet()); + this(name, documentReferences, Set.of()); } public NewDocumentType(Name name, @@ -74,8 +73,8 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp if (fs != null) { this.fieldSets.addAll(fs.userFieldSets().values()); for (FieldSet f : fs.builtInFieldSets().values()) { - if ((f.getName() != BuiltInFieldSets.INTERNAL_FIELDSET_NAME) && - (f.getName() != BuiltInFieldSets.SEARCH_FIELDSET_NAME)) { + if (!BuiltInFieldSets.INTERNAL_FIELDSET_NAME.equals(f.getName()) && + !BuiltInFieldSets.SEARCH_FIELDSET_NAME.equals(f.getName())) { fieldSets.add(f); } } diff --git a/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java b/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java index 2e964ac3624..749cdbfd8b7 100644 --- a/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java +++ b/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -351,7 +350,7 @@ public class ApplicationBuilder { RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryprofileRegistry) throws IOException, ParseException { - return createFromFiles(Collections.singletonList(fileName), new MockFileRegistry(), deployLogger, new TestProperties(), + return createFromFiles(List.of(fileName), new MockFileRegistry(), deployLogger, new TestProperties(), rankProfileRegistry, queryprofileRegistry); } @@ -414,8 +413,8 @@ public class ApplicationBuilder { queryProfileRegistry); var fnli = Files.list(new File(dir).toPath()) - .map(p -> p.toString()) - .filter(fn -> AbstractApplicationPackage.validSchemaFilename(fn)) + .map(java.nio.file.Path::toString) + .filter(AbstractApplicationPackage::validSchemaFilename) .sorted(); for (var i = fnli.iterator(); i.hasNext(); ) { builder.addSchemaFile(i.next()); diff --git a/config-model/src/main/java/com/yahoo/schema/FieldSets.java b/config-model/src/main/java/com/yahoo/schema/FieldSets.java index 1dbf496992b..6464bd1681e 100644 --- a/config-model/src/main/java/com/yahoo/schema/FieldSets.java +++ b/config-model/src/main/java/com/yahoo/schema/FieldSets.java @@ -47,11 +47,7 @@ public class FieldSets { * @param field field to add to field set */ public void addBuiltInFieldSetItem(String setName, String field) { - if (builtInFieldSets.get(setName) == null) { - // First entry in this set - builtInFieldSets.put(setName, new FieldSet(setName)); - } - builtInFieldSets.get(setName).addFieldName(field); + builtInFieldSets.computeIfAbsent(setName, FieldSet::new).addFieldName(field); } /** Returns the built in field sets, unmodifiable */ diff --git a/config-model/src/main/java/com/yahoo/schema/RankProfile.java b/config-model/src/main/java/com/yahoo/schema/RankProfile.java index 22bf1880cd7..82ed45028b3 100644 --- a/config-model/src/main/java/com/yahoo/schema/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/RankProfile.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -487,12 +486,12 @@ public class RankProfile implements Cloneable { } void setFirstPhaseRanking(RankingExpression rankingExpression) { - this.firstPhaseRanking = new RankingExpressionFunction(new ExpressionFunction(FIRST_PHASE, Collections.emptyList(), rankingExpression), false); + this.firstPhaseRanking = new RankingExpressionFunction(new ExpressionFunction(FIRST_PHASE, List.of(), rankingExpression), false); } public void setFirstPhaseRanking(String expression) { try { - firstPhaseRanking = new RankingExpressionFunction(parseRankingExpression(FIRST_PHASE, Collections.emptyList(), expression), false); + firstPhaseRanking = new RankingExpressionFunction(parseRankingExpression(FIRST_PHASE, List.of(), expression), false); } catch (ParseException e) { throw new IllegalArgumentException("Illegal first phase ranking function", e); } @@ -515,7 +514,7 @@ public class RankProfile implements Cloneable { public void setSecondPhaseRanking(String expression) { try { - secondPhaseRanking = new RankingExpressionFunction(parseRankingExpression(SECOND_PHASE, Collections.emptyList(), expression), false); + secondPhaseRanking = new RankingExpressionFunction(parseRankingExpression(SECOND_PHASE, List.of(), expression), false); } catch (ParseException e) { throw new IllegalArgumentException("Illegal second phase ranking function", e); @@ -535,7 +534,7 @@ public class RankProfile implements Cloneable { public void setGlobalPhaseRanking(String expression) { try { - globalPhaseRanking = new RankingExpressionFunction(parseRankingExpression(GLOBAL_PHASE, Collections.emptyList(), expression), false); + globalPhaseRanking = new RankingExpressionFunction(parseRankingExpression(GLOBAL_PHASE, List.of(), expression), false); } catch (ParseException e) { throw new IllegalArgumentException("Illegal global-phase ranking function", e); @@ -1036,7 +1035,7 @@ public class RankProfile implements Cloneable { Map<Reference, TensorType> featureTypes = featureTypes(); // Function compiling first pass: compile inline functions without resolving other functions Map<String, RankingExpressionFunction> inlineFunctions = - compileFunctions(this::getInlineFunctions, queryProfiles, featureTypes, importedModels, Collections.emptyMap(), expressionTransforms); + compileFunctions(this::getInlineFunctions, queryProfiles, featureTypes, importedModels, Map.of(), expressionTransforms); firstPhaseRanking = compile(this.getFirstPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms); secondPhaseRanking = compile(this.getSecondPhase(), queryProfiles, featureTypes, importedModels, constants(), inlineFunctions, expressionTransforms); diff --git a/config-model/src/main/java/com/yahoo/schema/derived/Deriver.java b/config-model/src/main/java/com/yahoo/schema/derived/Deriver.java index 9774868db9c..0c669e29538 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/Deriver.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/Deriver.java @@ -7,7 +7,6 @@ import com.yahoo.schema.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; import java.io.IOException; -import java.util.Collections; import java.util.List; /** @@ -30,7 +29,7 @@ public class Deriver { } public static DocumentmanagerConfig.Builder getDocumentManagerConfig(String sd) { - return getDocumentManagerConfig(Collections.singletonList(sd)); + return getDocumentManagerConfig(List.of(sd)); } public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> schemas) { @@ -38,7 +37,7 @@ public class Deriver { } public static DocumenttypesConfig.Builder getDocumentTypesConfig(String schema) { - return getDocumentTypesConfig(Collections.singletonList(schema)); + return getDocumentTypesConfig(List.of(schema)); } public static DocumenttypesConfig.Builder getDocumentTypesConfig(List<String> schemas) { diff --git a/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java b/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java index 34ed9f2f60c..677e4b31bdf 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java @@ -14,7 +14,6 @@ import com.yahoo.vespa.config.search.IndexschemaConfig; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -147,7 +146,7 @@ public class IndexSchema extends Derived { static List<Field> flattenField(Field field) { DataType fieldType = field.getDataType(); if (fieldType.getPrimitiveType() != null){ - return Collections.singletonList(field); + return List.of(field); } if (fieldType instanceof ArrayDataType) { List<Field> ret = new LinkedList<>(); diff --git a/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java b/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java index cb98cb79e01..7ade7ada061 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java @@ -10,7 +10,6 @@ import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -131,7 +130,7 @@ public class ImmutableImportedSDField implements ImmutableSDField { @Override public Map<String, String> getAliasToName() { - return Collections.emptyMap(); + return Map.of(); } @Override diff --git a/config-model/src/main/java/com/yahoo/schema/processing/IndexingOutputs.java b/config-model/src/main/java/com/yahoo/schema/processing/IndexingOutputs.java index be129b53c5e..b5d1cf71809 100644 --- a/config-model/src/main/java/com/yahoo/schema/processing/IndexingOutputs.java +++ b/config-model/src/main/java/com/yahoo/schema/processing/IndexingOutputs.java @@ -106,7 +106,7 @@ public class IndexingOutputs extends Processor { MyConverter(Schema schema, Field field, Set<String> summaryFields, boolean validate) { this.schema = schema; this.field = field; - this.summaryFields = summaryFields.isEmpty() ? Collections.singleton(field.getName()) : summaryFields; + this.summaryFields = summaryFields.isEmpty() ? Set.of(field.getName()) : summaryFields; this.validate = validate; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java b/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java index f1d3b38e8ff..348a5d575eb 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/HostPorts.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.model; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.provision.NetworkPorts; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -28,7 +27,7 @@ public class HostPorts { private int allocatedPorts = 0; - private PortFinder portFinder = new PortFinder(Collections.emptyList()); + private PortFinder portFinder = new PortFinder(List.of()); private boolean flushed = false; private Optional<NetworkPorts> networkPortsList = Optional.empty(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java index 1c4b0d31ab2..c876976917b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java @@ -36,7 +36,6 @@ import java.io.IOException; import java.time.Clock; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.logging.Level; @@ -96,7 +95,7 @@ public class VespaModelFactory implements ModelFactory { } else { this.configModelRegistry = configModelRegistry; } - this.modelImporters = Collections.emptyList(); + this.modelImporters = List.of(); this.additionalValidators = List.of(); this.zone = zone; this.clock = clock; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java index 78ef6826d26..c19d186df42 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerContainerCluster.java @@ -10,7 +10,6 @@ import com.yahoo.vespa.model.container.ContainerCluster; import com.yahoo.vespa.model.container.PlatformBundles; import java.nio.file.Path; -import java.util.Collections; import java.util.Optional; import java.util.Set; @@ -22,7 +21,7 @@ import java.util.Set; */ public class ClusterControllerContainerCluster extends ContainerCluster<ClusterControllerContainer> { - private static final Set<Path> UNNECESSARY_BUNDLES = Collections.unmodifiableSet(PlatformBundles.VESPA_SECURITY_BUNDLES); + private static final Set<Path> UNNECESSARY_BUNDLES = Set.copyOf(PlatformBundles.VESPA_SECURITY_BUNDLES); private final ReindexingContext reindexingContext; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java index 0d85696d503..913ae0e1a00 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java @@ -36,7 +36,6 @@ import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import java.nio.file.Path; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; @@ -198,7 +197,7 @@ public class MetricsProxyContainerCluster extends ContainerCluster<MetricsProxyC private Map<String, MetricsConsumer> getUserMetricsConsumers() { return getAdmin() .map(admin -> admin.getUserMetrics().getConsumers()) - .orElse(Collections.emptyMap()); + .orElse(Map.of()); } private Optional<String> getSystemName() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/ComponentsBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/ComponentsBuilder.java index 046980087ed..bde12bb1d5a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/ComponentsBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/ComponentsBuilder.java @@ -151,7 +151,7 @@ public class ComponentsBuilder<T extends ChainedComponent<?>> { private Map<String, ComponentType<?>> unmodifiable(Map<String, ComponentType<?>> outerComponentTypeByComponentName) { return (outerComponentTypeByComponentName != null)? Collections.unmodifiableMap(outerComponentTypeByComponentName): - Collections.emptyMap(); + Map.of(); } public Collection<T> getComponentDefinitions() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java index baa9c4b9a48..9f91f6bf5e1 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java @@ -69,7 +69,7 @@ public class PlatformBundles { private static Set<Path> toBundlePaths(String... bundleNames) { return Stream.of(bundleNames) .map(PlatformBundles::absoluteBundlePath) - .collect(Collectors.toSet()); + .collect(Collectors.toUnmodifiableSet()); } public static Path absoluteBundlePath(String fileName) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/DiscBindingsConfigGenerator.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/DiscBindingsConfigGenerator.java index ed626f98aa0..dafac2c1af9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/DiscBindingsConfigGenerator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/DiscBindingsConfigGenerator.java @@ -2,7 +2,6 @@ package com.yahoo.vespa.model.container.component; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -24,9 +23,9 @@ public class DiscBindingsConfigGenerator { public static <T extends Handler> Map<String, Handlers.Builder> generate(T handler) { if (handler.getServerBindings().isEmpty() && handler.getClientBindings().isEmpty()) - return Collections.emptyMap(); + return Map.of(); - return Collections.singletonMap(handler.model.getComponentId().stringValue(), + return Map.of(handler.model.getComponentId().stringValue(), new Handlers.Builder() .serverBindings(toStrings(handler.getServerBindings())) .clientBindings(toStrings(handler.getClientBindings()))); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/AccessControl.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/AccessControl.java index 8c1b868465a..19c45bba2ef 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/AccessControl.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/AccessControl.java @@ -48,7 +48,7 @@ public class AccessControl { private final String domain; private ClientAuthentication clientAuthentication = ClientAuthentication.need; private final Set<BindingPattern> excludeBindings = new LinkedHashSet<>(); - private Collection<Handler> handlers = Collections.emptyList(); + private Collection<Handler> handlers = List.of(); public Builder(String domain) { this.domain = domain; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainBuilder.java index bc234546625..82a8a01871e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainBuilder.java @@ -11,7 +11,7 @@ import com.yahoo.vespa.model.container.http.HttpFilterChain; import org.w3c.dom.Element; import java.util.Collection; -import java.util.Collections; +import java.util.List; import java.util.Map; import static com.yahoo.vespa.model.builder.xml.dom.chains.ComponentsBuilder.ComponentType; @@ -21,7 +21,7 @@ import static com.yahoo.vespa.model.builder.xml.dom.chains.ComponentsBuilder.Com */ public class FilterChainBuilder extends DomChainBuilderBase<Filter, HttpFilterChain> { - private static final Collection<ComponentType<Filter>> allowedComponentTypes = Collections.singleton(ComponentType.filter); + private static final Collection<ComponentType<Filter>> allowedComponentTypes = List.of(ComponentType.filter); public FilterChainBuilder(Map<String, ComponentType<?>> outerFilterTypeByComponentName) { super(allowedComponentTypes, outerFilterTypeByComponentName); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainsBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainsBuilder.java index 878859a01bf..f1cdbfb3b04 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainsBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/http/xml/FilterChainsBuilder.java @@ -15,7 +15,6 @@ import com.yahoo.vespa.model.container.http.HttpFilterChain; import org.w3c.dom.Element; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -24,7 +23,7 @@ import java.util.Map; */ public class FilterChainsBuilder extends DomChainsBuilder<Filter, HttpFilterChain, FilterChains> { private static final Collection<ComponentType<Filter>> allowedComponentTypes = - Collections.singleton(ComponentType.filter); + List.of(ComponentType.filter); private static final Map<String, Class<? extends DomChainBuilderBase<? extends Filter, ? extends HttpFilterChain>>> chainType2BuilderClass = Map.of( diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 456ce8fdbc2..360a02256a9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -114,7 +114,6 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -893,7 +892,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private void addStandaloneNode(ApplicationContainerCluster cluster, DeployState deployState) { ApplicationContainer container = new ApplicationContainer(cluster, "standalone", cluster.getContainers().size(), deployState); - cluster.addContainers(Collections.singleton(container)); + cluster.addContainers(List.of(container)); } private static String buildJvmGCOptions(ConfigModelContext context, String jvmGCOptions) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java index 9d15eddbef3..6d482a6d4a6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java @@ -35,7 +35,6 @@ import org.w3c.dom.Element; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Optional; @@ -195,7 +194,7 @@ public class Content extends ConfigModel { public static class Builder extends ConfigModelBuilder<Content> { - public static final List<ConfigModelId> configModelIds = Collections.singletonList(ConfigModelId.fromName("content")); + public static final List<ConfigModelId> configModelIds = List.of(ConfigModelId.fromName("content")); public Builder() { super(Content.class); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java index a6f53777c51..a1b9ed67aa7 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java @@ -19,7 +19,6 @@ import com.yahoo.vespa.model.content.engines.PersistenceEngine; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -349,7 +348,7 @@ public class StorageGroup { owner.getStorageCluster().getClusterName(), owner.getRoot().hostSystem(), context) : - Collections.emptyMap(); + Map.of(); Map<Optional<ClusterSpec.Group>, Map<HostResource, ClusterMembership>> hostGroups = collectAllocatedSubgroups(hostMapping); if (hostGroups.size() > 1) { @@ -475,7 +474,7 @@ public class StorageGroup { } private List<XmlNodeBuilder> collectExplicitNodes(Optional<ModelElement> groupOrNodesElement) { - if (groupOrNodesElement.isEmpty()) return Collections.emptyList(); + if (groupOrNodesElement.isEmpty()) return List.of(); List<XmlNodeBuilder> nodes = new ArrayList<>(); for (ModelElement n : groupOrNodesElement.get().subElements("node")) nodes.add(new XmlNodeBuilder(clusterElement, n)); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java index c9b6537434b..07dafda164d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilder.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.model.content.cluster; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.vespa.model.builder.xml.dom.ModelElement; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -20,19 +19,19 @@ public class GlobalDistributionBuilder { private final Map<String, NewDocumentType> documentDefinitions; public GlobalDistributionBuilder(Map<String, NewDocumentType> documentDefinitions) { - this.documentDefinitions = Collections.unmodifiableMap(documentDefinitions); + this.documentDefinitions = Map.copyOf(documentDefinitions); } public Set<NewDocumentType> build(ModelElement documentsElement) { if (documentsElement == null || documentsElement.subElements("document").isEmpty()) - return Collections.emptySet(); + return Set.of(); return documentsElement.subElements("document") .stream() .filter(GlobalDistributionBuilder::isGloballyDistributed) .map(GlobalDistributionBuilder::getDocumentName) .map(this::getDocumentType) - .collect(Collectors.toCollection(() -> new LinkedHashSet<>())); + .collect(Collectors.toCollection(LinkedHashSet::new)); } private static boolean isGloballyDistributed(ModelElement e) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java index 621377e0606..78ed10a583e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java @@ -32,7 +32,6 @@ import java.io.StringReader; import java.io.UncheckedIOException; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -177,7 +176,7 @@ public class ConvertedModel { if (arguments.output().isEmpty()) { List<Map.Entry<String, ExpressionFunction>> entriesWithTheRightPrefix = expressions.entrySet().stream().filter(entry -> entry.getKey().startsWith(arguments.signature().get() + ".")).toList(); - if (entriesWithTheRightPrefix.size() < 1) + if (entriesWithTheRightPrefix.isEmpty()) throw new IllegalArgumentException("No expressions named '" + arguments.signature().get() + missingExpressionMessageSuffix()); if (entriesWithTheRightPrefix.size() > 1) @@ -191,7 +190,7 @@ public class ConvertedModel { private String missingExpressionMessageSuffix() { return "' in model '" + modelDescription + "'. " + - "Available expressions: " + expressions.keySet().stream().collect(Collectors.joining(", ")); + "Available expressions: " + String.join(", ", expressions.keySet()); } // ----------------------- Static model conversion/storage below here @@ -425,8 +424,7 @@ public class ConvertedModel { } private static void addFunctionNamesIn(ExpressionNode node, Set<String> names, ImportedMlModel model) { - if (node instanceof ReferenceNode) { - ReferenceNode referenceNode = (ReferenceNode)node; + if (node instanceof ReferenceNode referenceNode) { if (referenceNode.getOutput() == null) { // function references cannot specify outputs if (names.add(referenceNode.getName())) { if (model.functions().containsKey(referenceNode.getName())) { @@ -485,7 +483,7 @@ public class ConvertedModel { List<Pair<String, ExpressionFunction>> readExpressions() { List<Pair<String, ExpressionFunction>> expressions = new ArrayList<>(); ApplicationFile expressionPath = application.getFile(modelFiles.expressionsPath()); - if ( ! expressionPath.exists() || ! expressionPath.isDirectory()) return Collections.emptyList(); + if ( ! expressionPath.exists() || ! expressionPath.isDirectory()) return List.of(); for (ApplicationFile expressionFile : expressionPath.listFiles()) { try (BufferedReader reader = new BufferedReader(expressionFile.createReader())) { String name = expressionFile.getPath().getName(); @@ -525,7 +523,7 @@ public class ConvertedModel { List<Pair<String, RankingExpression>> readFunctions() { try { ApplicationFile file = application.getFile(modelFiles.functionsPath()); - if ( ! file.exists()) return Collections.emptyList(); + if ( ! file.exists()) return List.of(); List<Pair<String, RankingExpression>> functions = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(file.createReader())) { @@ -597,7 +595,7 @@ public class ConvertedModel { private List<Pair<String, Tensor>> readSmallConstants() { try { ApplicationFile file = application.getFile(modelFiles.smallConstantsPath()); - if ( ! file.exists()) return Collections.emptyList(); + if ( ! file.exists()) return List.of(); List<Pair<String, Tensor>> constants = new ArrayList<>(); BufferedReader reader = new BufferedReader(file.createReader()); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java index 502924ed31a..f47a48b09d7 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java @@ -17,7 +17,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -51,8 +50,8 @@ public class OnnxModelInfo { Map<String, OnnxTypeInfo> outputs, Set<String> initializers, String defaultOutput) { this.app = app; this.modelPath = path; - this.inputs = Collections.unmodifiableMap(inputs); - this.outputs = Collections.unmodifiableMap(outputs); + this.inputs = Map.copyOf(inputs); + this.outputs = Map.copyOf(outputs); this.defaultOutput = defaultOutput; this.initializers = Set.copyOf(initializers); } |