aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java14
1 files changed, 6 insertions, 8 deletions
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());