From d61c151211024dbb5e9a5d71ac921217ae00f34b Mon Sep 17 00:00:00 2001 From: jonmv Date: Tue, 10 Oct 2023 14:10:55 +0200 Subject: Non-functional changes --- .../yahoo/document/annotation/ListAnnotationContainer.java | 6 +++--- .../java/com/yahoo/document/annotation/SpanNodeParent.java | 6 +++--- .../main/java/com/yahoo/document/annotation/SpanTree.java | 14 +++++++------- .../com/yahoo/document/datatypes/StringFieldValue.java | 2 +- .../java/com/yahoo/document/datatypes/ArrayTestCase.java | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'document') diff --git a/document/src/main/java/com/yahoo/document/annotation/ListAnnotationContainer.java b/document/src/main/java/com/yahoo/document/annotation/ListAnnotationContainer.java index 966a7347173..e27957519c9 100644 --- a/document/src/main/java/com/yahoo/document/annotation/ListAnnotationContainer.java +++ b/document/src/main/java/com/yahoo/document/annotation/ListAnnotationContainer.java @@ -10,10 +10,10 @@ import java.util.ListIterator; import java.util.NoSuchElementException; /** - * @author Einar M R Rosenvinge + * @author Einar M R Rosenvinge */ public class ListAnnotationContainer extends IteratingAnnotationContainer { - private final List annotations = new LinkedList(); + private final List annotations = new LinkedList<>(); @Override void annotateAll(Collection annotations) { @@ -55,7 +55,7 @@ public class ListAnnotationContainer extends IteratingAnnotationContainer { private boolean nextCalled = false; AnnotationIterator(ListIterator baseIt, IdentityHashMap nodes) { - this.base = new PeekableListIterator(baseIt); + this.base = new PeekableListIterator(baseIt); this.nodes = nodes; } diff --git a/document/src/main/java/com/yahoo/document/annotation/SpanNodeParent.java b/document/src/main/java/com/yahoo/document/annotation/SpanNodeParent.java index fa2f546a338..b1726d7da80 100644 --- a/document/src/main/java/com/yahoo/document/annotation/SpanNodeParent.java +++ b/document/src/main/java/com/yahoo/document/annotation/SpanNodeParent.java @@ -6,7 +6,7 @@ import com.yahoo.document.datatypes.StringFieldValue; /** * An interface to be implemented by classes that can be parents of SpanNodes. * - * @author Einar M R Rosenvinge + * @author Einar M R Rosenvinge * @see SpanNode#getParent() */ public interface SpanNodeParent { @@ -15,12 +15,12 @@ public interface SpanNodeParent { * * @return the SpanTree of this, if it belongs to a SpanTree, otherwise null. */ - public SpanTree getSpanTree(); + SpanTree getSpanTree(); /** * Returns the StringFieldValue that this node belongs to, if any. * * @return the StringFieldValue that this node belongs to, if any, otherwise null. */ - public StringFieldValue getStringFieldValue(); + StringFieldValue getStringFieldValue(); } diff --git a/document/src/main/java/com/yahoo/document/annotation/SpanTree.java b/document/src/main/java/com/yahoo/document/annotation/SpanTree.java index d63616130e2..a588f9d97b8 100644 --- a/document/src/main/java/com/yahoo/document/annotation/SpanTree.java +++ b/document/src/main/java/com/yahoo/document/annotation/SpanTree.java @@ -22,7 +22,7 @@ import java.util.Map; /** * A SpanTree holds a root node of a tree of SpanNodes, and a List of Annotations pointing to these nodes - * or each other. It also has a name. + * or each other. It also has a name. * * @author Einar M R Rosenvinge * @see com.yahoo.document.annotation.SpanNode @@ -36,7 +36,7 @@ public class SpanTree implements Iterable, SpanNodeParent, Comparabl private StringFieldValue stringFieldValue; /** - * WARNING! Only to be used by deserializers! Creates an empty SpanTree instance. + * WARNING! Only to be used by deserializers! Creates an empty SpanTree instance. */ public SpanTree() { } @@ -65,8 +65,8 @@ public class SpanTree implements Iterable, SpanNodeParent, Comparabl public SpanTree(SpanTree otherToCopy) { name = otherToCopy.name; setRoot(copySpan(otherToCopy.root)); - List annotationsToCopy = new ArrayList(otherToCopy.getAnnotations()); - List newAnnotations = new ArrayList(annotationsToCopy.size()); + List annotationsToCopy = new ArrayList<>(otherToCopy.getAnnotations()); + List newAnnotations = new ArrayList<>(annotationsToCopy.size()); for (Annotation otherAnnotationToCopy : annotationsToCopy) { newAnnotations.add(new Annotation(otherAnnotationToCopy)); @@ -153,7 +153,7 @@ public class SpanTree implements Iterable, SpanNodeParent, Comparabl } private IdentityHashMap getAnnotations(List annotationsToCopy) { - IdentityHashMap map = new IdentityHashMap(); + IdentityHashMap map = new IdentityHashMap<>(); for (int i = 0; i < annotationsToCopy.size(); i++) { map.put(annotationsToCopy.get(i), i); } @@ -162,7 +162,7 @@ public class SpanTree implements Iterable, SpanNodeParent, Comparabl private List getSpanNodes() { - ArrayList nodes = new ArrayList(); + ArrayList nodes = new ArrayList<>(); nodes.add(root); Iterator it = root.childIteratorRecursive(); while (it.hasNext()) { @@ -172,7 +172,7 @@ public class SpanTree implements Iterable, SpanNodeParent, Comparabl } private static IdentityHashMap getSpanNodes(SpanTree otherToCopy) { - IdentityHashMap map = new IdentityHashMap(); + IdentityHashMap map = new IdentityHashMap<>(); int spanNodeCounter = 0; map.put(otherToCopy.getRoot(), spanNodeCounter++); Iterator it = otherToCopy.getRoot().childIteratorRecursive(); diff --git a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java index 6e999bb4041..c87a923ac83 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java @@ -106,7 +106,7 @@ public class StringFieldValue extends FieldValue { } /** - * Sets a new value for this StringFieldValue. NOTE that doing so will clear all span trees from this value, + * Sets a new value for this StringFieldValue. NOTE that doing so will clear all span trees from this value, * since they most certainly will not make sense for a new string value. * * @param o the new String to assign to this. An argument of null is equal to calling clear(). diff --git a/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java index cafaafd7326..c801454bf94 100755 --- a/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java +++ b/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java @@ -77,7 +77,7 @@ public class ArrayTestCase { @Test public void testWrappedList() { - Array array = new Array(DataType.getArray(DataType.STRING)); + Array array = new Array<>(DataType.getArray(DataType.STRING)); List list = new ArrayList<>(); list.add("foo"); list.add("bar"); @@ -217,10 +217,10 @@ public class ArrayTestCase { assertEquals(new StringFieldValue("apple"), subArray.get(1)); - assertEquals(false, array.containsAll(Arrays.asList(new StringFieldValue("bob")))); - assertEquals(true, array.containsAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"), new StringFieldValue("apple")))); + assertEquals(false, array.containsAll(Arrays.asList(new StringFieldValue("bob")))); + assertEquals(true, array.containsAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"), new StringFieldValue("apple")))); - array.removeAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"))); + array.removeAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"))); assertEquals(1, array.size()); assertEquals(1, list.size()); @@ -249,7 +249,7 @@ public class ArrayTestCase { assertFalse(it.hasNext()); } - array.addAll(Arrays.asList(new StringFieldValue("microsoft"), new StringFieldValue("google"))); + array.addAll(Arrays.asList(new StringFieldValue("microsoft"), new StringFieldValue("google"))); assertEquals(4, array.size()); assertEquals(4, list.size()); -- cgit v1.2.3 From 9922b8c1681a817d9a9c84d3a967a5120e8c0599 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Wed, 11 Oct 2023 12:13:21 +0200 Subject: Arrays.asList -> List.of --- .../src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'document') diff --git a/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java index c801454bf94..4c4b9f9fc78 100755 --- a/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java +++ b/document/src/test/java/com/yahoo/document/datatypes/ArrayTestCase.java @@ -217,10 +217,10 @@ public class ArrayTestCase { assertEquals(new StringFieldValue("apple"), subArray.get(1)); - assertEquals(false, array.containsAll(Arrays.asList(new StringFieldValue("bob")))); - assertEquals(true, array.containsAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"), new StringFieldValue("apple")))); + assertEquals(false, array.containsAll(List.of(new StringFieldValue("bob")))); + assertEquals(true, array.containsAll(List.of(new StringFieldValue("foo"), new StringFieldValue("boo"), new StringFieldValue("apple")))); - array.removeAll(Arrays.asList(new StringFieldValue("foo"), new StringFieldValue("boo"))); + array.removeAll(List.of(new StringFieldValue("foo"), new StringFieldValue("boo"))); assertEquals(1, array.size()); assertEquals(1, list.size()); @@ -249,7 +249,7 @@ public class ArrayTestCase { assertFalse(it.hasNext()); } - array.addAll(Arrays.asList(new StringFieldValue("microsoft"), new StringFieldValue("google"))); + array.addAll(List.of(new StringFieldValue("microsoft"), new StringFieldValue("google"))); assertEquals(4, array.size()); assertEquals(4, list.size()); -- cgit v1.2.3