aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 10:27:59 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 16:07:22 +0200
commit48b9513ee685145d338e0cf9970193ba8254ce33 (patch)
treed9f489b0c1ffd448bc067441b032adfb1c379f1b /vespajlib
parentef1cf91e0d21ceb4c40d1a6efd62d3dabd08cb86 (diff)
Unify on Set.of
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/LazyMap.java3
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/LazySetTest.java22
2 files changed, 12 insertions, 13 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/LazyMap.java b/vespajlib/src/main/java/com/yahoo/collections/LazyMap.java
index 9d0df495f9a..c979d746243 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/LazyMap.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/LazyMap.java
@@ -4,7 +4,6 @@ package com.yahoo.collections;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -129,7 +128,7 @@ public abstract class LazyMap<K, V> implements Map<K, V> {
@Override
public Set<Entry<K, V>> entrySet() {
- return Collections.emptySet();
+ return Set.of();
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/collections/LazySetTest.java b/vespajlib/src/test/java/com/yahoo/collections/LazySetTest.java
index ecefd891ca9..8450c7986ef 100644
--- a/vespajlib/src/test/java/com/yahoo/collections/LazySetTest.java
+++ b/vespajlib/src/test/java/com/yahoo/collections/LazySetTest.java
@@ -4,11 +4,11 @@ package com.yahoo.collections;
import org.junit.Test;
import org.mockito.Mockito;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -26,25 +26,25 @@ public class LazySetTest {
@Test
public void requireThatInitialDelegateIsEmpty() {
- LazySet<String> set = newLazySet(new HashSet<String>());
+ LazySet<String> set = newLazySet(new HashSet<>());
assertEquals(LazySet.EmptySet.class, set.getDelegate().getClass());
}
@Test
public void requireThatEmptySetAddUpgradesToSingletonSet() {
- LazySet<String> set = newLazySet(new HashSet<String>());
+ LazySet<String> set = newLazySet(new HashSet<>());
assertTrue(set.add("foo"));
assertEquals(LazySet.SingletonSet.class, set.getDelegate().getClass());
- set = newLazySet(new HashSet<String>());
- assertTrue(set.addAll(Arrays.asList("foo")));
+ set = newLazySet(new HashSet<>());
+ assertTrue(set.addAll(List.of("foo")));
assertEquals(LazySet.SingletonSet.class, set.getDelegate().getClass());
}
@Test
public void requireThatEmptySetAddAllEmptySetDoesNotUpgradeToSingletonSet() {
- LazySet<String> set = newLazySet(new HashSet<String>());
- assertFalse(set.addAll(Collections.<String>emptySet()));
+ LazySet<String> set = newLazySet(new HashSet<>());
+ assertFalse(set.addAll(Set.of()));
assertEquals(LazySet.EmptySet.class, set.getDelegate().getClass());
}
@@ -52,7 +52,7 @@ public class LazySetTest {
public void requireThatEmptySetAddAllUpgradesToFinalSet() {
Set<String> delegate = new HashSet<>();
LazySet<String> set = newLazySet(delegate);
- assertTrue(set.addAll(Arrays.asList("foo", "bar")));
+ assertTrue(set.addAll(List.of("foo", "bar")));
assertSame(delegate, set.getDelegate());
assertEquals(2, delegate.size());
assertTrue(delegate.contains("foo"));
@@ -76,7 +76,7 @@ public class LazySetTest {
@Test
public void requireThatSingletonSetAddAllEmptySetDoesNotUpgradeToFinalSet() {
LazySet<String> set = newSingletonSet("foo");
- assertFalse(set.addAll(Collections.<String>emptySet()));
+ assertFalse(set.addAll(Set.of()));
assertEquals(LazySet.SingletonSet.class, set.getDelegate().getClass());
}
@@ -102,7 +102,7 @@ public class LazySetTest {
public void requireThatSingletonSetAddAllUpgradesToFinalSet() {
Set<String> delegate = new HashSet<>();
LazySet<String> set = newSingletonSet(delegate, "foo");
- assertTrue(set.addAll(Arrays.asList("bar")));
+ assertTrue(set.addAll(List.of("bar")));
assertSame(delegate, set.getDelegate());
assertEquals(2, delegate.size());
assertTrue(delegate.contains("foo"));
@@ -110,7 +110,7 @@ public class LazySetTest {
delegate = new HashSet<>();
set = newSingletonSet(delegate, "foo");
- assertTrue(set.addAll(Arrays.asList("bar", "baz")));
+ assertTrue(set.addAll(List.of("bar", "baz")));
assertSame(delegate, set.getDelegate());
assertEquals(3, delegate.size());
assertTrue(delegate.contains("foo"));