diff options
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/di')
7 files changed, 12 insertions, 23 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java b/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java index fcccc02d143..5a04bd8eae1 100644 --- a/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java +++ b/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java @@ -8,7 +8,6 @@ import com.yahoo.container.di.config.Subscriber; import com.yahoo.container.di.config.SubscriberFactory; import com.yahoo.vespa.config.ConfigKey; -import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Optional; @@ -135,7 +134,7 @@ public final class ConfigRetriever { private void resetComponentSubscriberIfBootstrap(ConfigSnapshot configSnapshot) { if (configSnapshot instanceof BootstrapConfigs) { - setupComponentSubscriber(Collections.emptySet()); + setupComponentSubscriber(Set.of()); } } diff --git a/container-core/src/main/java/com/yahoo/container/di/Osgi.java b/container-core/src/main/java/com/yahoo/container/di/Osgi.java index 0ff640031fc..7bab8605a3e 100644 --- a/container-core/src/main/java/com/yahoo/container/di/Osgi.java +++ b/container-core/src/main/java/com/yahoo/container/di/Osgi.java @@ -10,8 +10,6 @@ import org.osgi.framework.Bundle; import java.util.Collection; import java.util.Set; -import static java.util.Collections.emptySet; - /** * This interface has default implementations of all methods, to allow using it * for testing, instead of mocking or a test implementation. @@ -49,7 +47,7 @@ public interface Osgi { * @return The set of bundles that are no longer needed by the new or latest good generation. */ default Set<Bundle> completeBundleGeneration(GenerationStatus status) { - return emptySet(); + return Set.of(); } default Class<?> resolveClass(BundleInstantiationSpecification spec) { diff --git a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentGraph.java b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentGraph.java index 98b4d0f4d63..5db57250bdf 100644 --- a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentGraph.java +++ b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentGraph.java @@ -23,7 +23,6 @@ import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -369,7 +368,7 @@ public class ComponentGraph { public static boolean isBindingAnnotation(Annotation annotation) { LinkedList<Class<?>> queue = new LinkedList<>(); queue.add(annotation.getClass()); - queue.addAll(Arrays.asList(annotation.getClass().getInterfaces())); + queue.addAll(List.of(annotation.getClass().getInterfaces())); while (!queue.isEmpty()) { Class<?> clazz = queue.removeFirst(); diff --git a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java index 4500a5636f4..dcc024ef2b1 100644 --- a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java +++ b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java @@ -199,7 +199,7 @@ public class ComponentNode extends Node { @Override public boolean equals(Object other) { if (other instanceof ComponentNode that) { - return super.equals(that) && equalEdges(Arrays.asList(this.arguments), Arrays.asList(that.arguments)) && this.usedConfigs().equals(that.usedConfigs()); + return super.equals(that) && equalEdges(List.of(this.arguments), List.of(that.arguments)) && this.usedConfigs().equals(that.usedConfigs()); } else { return false; } @@ -225,7 +225,7 @@ public class ComponentNode extends Node { List<Pair<Type, List<Annotation>>> ret = new ArrayList<>(); for (int i = 0; i < types.length; i++) { - ret.add(new Pair<>(types[i], Arrays.asList(annotations[i]))); + ret.add(new Pair<>(types[i], List.of(annotations[i]))); } return ret; } diff --git a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentRegistryNode.java b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentRegistryNode.java index ca10072c6c9..8b5fb128e2b 100644 --- a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentRegistryNode.java +++ b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentRegistryNode.java @@ -8,10 +8,8 @@ import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.config.ConfigInstance; import com.yahoo.vespa.config.ConfigKey; -import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; /** * @author Tony Vaagenes @@ -20,7 +18,7 @@ import java.util.stream.Collectors; */ public class ComponentRegistryNode extends Node { - private static ComponentId componentRegistryNamespace = ComponentId.fromString("ComponentRegistry"); + private static final ComponentId componentRegistryNamespace = ComponentId.fromString("ComponentRegistry"); private final Class<?> componentClass; @@ -63,7 +61,7 @@ public class ComponentRegistryNode extends Node { @Override public Set<ConfigKey<ConfigInstance>> configKeys() { - return Collections.emptySet(); + return Set.of(); } @Override @@ -76,8 +74,7 @@ public class ComponentRegistryNode extends Node { @Override public boolean equals(Object other) { - if (other instanceof ComponentRegistryNode) { - ComponentRegistryNode that = (ComponentRegistryNode) other; + if (other instanceof ComponentRegistryNode that) { return this.componentId().equals(that.componentId()) && this.instanceType().equals(that.instanceType()) && equalNodeEdges(this.usedComponents(), that.usedComponents()); } else { diff --git a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/GuiceNode.java b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/GuiceNode.java index 936eadb0b3c..8e6a39a4921 100644 --- a/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/GuiceNode.java +++ b/container-core/src/main/java/com/yahoo/container/di/componentgraph/core/GuiceNode.java @@ -7,7 +7,6 @@ import com.yahoo.config.ConfigInstance; import com.yahoo.vespa.config.ConfigKey; import java.lang.annotation.Annotation; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -24,8 +23,7 @@ public final class GuiceNode extends Node { private final Object myInstance; private final Annotation annotation; - public GuiceNode(Object myInstance, - Annotation annotation) { + public GuiceNode(Object myInstance, Annotation annotation) { super(componentId(myInstance)); this.myInstance = myInstance; this.annotation = annotation; @@ -33,7 +31,7 @@ public final class GuiceNode extends Node { @Override public Set<ConfigKey<ConfigInstance>> configKeys() { - return Collections.emptySet(); + return Set.of(); } @Override @@ -54,7 +52,7 @@ public final class GuiceNode extends Node { @Override public List<Node> usedComponents() { - return Collections.emptyList(); + return List.of(); } @Override diff --git a/container-core/src/main/java/com/yahoo/container/di/componentgraph/cycle/CycleFinder.java b/container-core/src/main/java/com/yahoo/container/di/componentgraph/cycle/CycleFinder.java index f8fa0756cb3..6364eab6d42 100644 --- a/container-core/src/main/java/com/yahoo/container/di/componentgraph/cycle/CycleFinder.java +++ b/container-core/src/main/java/com/yahoo/container/di/componentgraph/cycle/CycleFinder.java @@ -6,13 +6,11 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; -import java.util.stream.Collectors; import static com.yahoo.container.di.componentgraph.cycle.CycleFinder.State.BLACK; import static com.yahoo.container.di.componentgraph.cycle.CycleFinder.State.GRAY; import static com.yahoo.container.di.componentgraph.cycle.CycleFinder.State.WHITE; import static java.util.logging.Level.FINE; -import static java.util.Collections.singletonList; /** @@ -55,7 +53,7 @@ public class CycleFinder<T> { resetState(); for (T vertex : graph.getVertices()) { if (colors.get(vertex) == WHITE) { - if (visitDepthFirst(vertex, new ArrayList<>(singletonList(vertex)))) { + if (visitDepthFirst(vertex, new ArrayList<>(List.of(vertex)))) { if (cycle == null) throw new IllegalStateException("Null cycle - this should never happen"); if (cycle.isEmpty()) throw new IllegalStateException("Empty cycle - this should never happen"); log.log(FINE, () -> "Cycle detected: " + cycle); |