From cfa8299116fbe747c303719ab31c34e506b52c41 Mon Sep 17 00:00:00 2001 From: amihaiemil Date: Thu, 4 Apr 2024 19:18:51 +0300 Subject: [PATCH] #617 Removed method YamlLines.original() --- .../com/amihaiemil/eoyaml/AllYamlLines.java | 5 ----- .../java/com/amihaiemil/eoyaml/Backwards.java | 5 ----- .../amihaiemil/eoyaml/CollapsedFlowLines.java | 6 ------ .../amihaiemil/eoyaml/FirstCommentFound.java | 6 ------ .../amihaiemil/eoyaml/GreaterIndentation.java | 6 ------ .../com/amihaiemil/eoyaml/ReadYamlStream.java | 2 +- .../eoyaml/SameIndentationLevel.java | 6 ------ src/main/java/com/amihaiemil/eoyaml/Skip.java | 6 ------ .../com/amihaiemil/eoyaml/StartMarkers.java | 6 ------ .../com/amihaiemil/eoyaml/WellIndented.java | 6 ------ .../java/com/amihaiemil/eoyaml/YamlLines.java | 12 ----------- .../com/amihaiemil/eoyaml/BackwardsTest.java | 15 ------------- .../eoyaml/FirstCommentFoundTest.java | 14 ------------- .../eoyaml/SameIndentationLevelTestCase.java | 21 ------------------- .../java/com/amihaiemil/eoyaml/SkipTest.java | 15 ------------- .../amihaiemil/eoyaml/StartMarkersTest.java | 16 -------------- .../amihaiemil/eoyaml/WellIndentedTest.java | 16 -------------- 17 files changed, 1 insertion(+), 162 deletions(-) diff --git a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java index 45e2d081..dbddb996 100644 --- a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java +++ b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java @@ -98,11 +98,6 @@ public String toString() { return builder.toString(); } - @Override - public Collection original() { - return this.lines; - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { final YamlNode node; diff --git a/src/main/java/com/amihaiemil/eoyaml/Backwards.java b/src/main/java/com/amihaiemil/eoyaml/Backwards.java index 8ac4bdc1..bbebcafe 100644 --- a/src/main/java/com/amihaiemil/eoyaml/Backwards.java +++ b/src/main/java/com/amihaiemil/eoyaml/Backwards.java @@ -50,11 +50,6 @@ final class Backwards implements YamlLines { this.lines = lines; } - @Override - public Collection original() { - return this.lines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.lines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/CollapsedFlowLines.java b/src/main/java/com/amihaiemil/eoyaml/CollapsedFlowLines.java index 35988e42..0e4557bd 100644 --- a/src/main/java/com/amihaiemil/eoyaml/CollapsedFlowLines.java +++ b/src/main/java/com/amihaiemil/eoyaml/CollapsedFlowLines.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -96,11 +95,6 @@ final class CollapsedFlowLines implements YamlLines { this.closingBracket = closingBracket; } - @Override - public Collection original() { - return this.lines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.lines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java b/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java index 173cc8e2..38d5c982 100644 --- a/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java +++ b/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -88,11 +87,6 @@ public Iterator iterator() { return iterator; } - @Override - public Collection original() { - return this.lines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.lines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java index 99286fa7..d9aab8e2 100644 --- a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java +++ b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -90,11 +89,6 @@ public Iterator iterator() { return iterator; } - @Override - public Collection original() { - return this.yamlLines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.yamlLines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java index 1db9a1fd..9dd3572a 100644 --- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java +++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java @@ -74,7 +74,7 @@ public Collection values() { final List values = new ArrayList<>(); for(final YamlLine startDoc : this.startMarkers) { final YamlLines document = this.readDocument(startDoc); - if(!document.original().isEmpty()) { + if(document.iterator().hasNext()) { values.add( document.nextYamlNode(startDoc) ); diff --git a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java index ef0cec8f..a60c4bbd 100644 --- a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java +++ b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -111,11 +110,6 @@ public Iterator iterator() { return iterator; } - @Override - public Collection original() { - return this.yamlLines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.yamlLines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/Skip.java b/src/main/java/com/amihaiemil/eoyaml/Skip.java index 35544006..7aadc97f 100644 --- a/src/main/java/com/amihaiemil/eoyaml/Skip.java +++ b/src/main/java/com/amihaiemil/eoyaml/Skip.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -89,11 +88,6 @@ public Iterator iterator() { return iterator; } - @Override - public Collection original() { - return this.yamlLines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.yamlLines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java index 1c19e4d1..0f23973e 100644 --- a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java +++ b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java @@ -28,7 +28,6 @@ package com.amihaiemil.eoyaml; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -97,11 +96,6 @@ public Iterator iterator() { return iterator; } - @Override - public Collection original() { - return this.yamlLines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.yamlLines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java index 053e4597..6f50d7cc 100644 --- a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java +++ b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java @@ -29,7 +29,6 @@ import com.amihaiemil.eoyaml.exceptions.YamlIndentationException; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -144,11 +143,6 @@ public Iterator iterator() { return wellIndented.iterator(); } - @Override - public Collection original() { - return this.yamlLines.original(); - } - @Override public YamlNode nextYamlNode(final YamlLine prev) { return this.yamlLines.nextYamlNode(prev); diff --git a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java index 95c9a5ae..1d39a15f 100644 --- a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java +++ b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java @@ -27,7 +27,6 @@ */ package com.amihaiemil.eoyaml; -import java.util.Collection; import java.util.Iterator; /** @@ -38,17 +37,6 @@ */ interface YamlLines extends Iterable { - /** - * Return all the original underlying lines. No matter what - * decorators are added on top of the base YamlLines implementation, - * the call to this method should always be delegated down to the - * base method, with no changes. - * @return The original YamlLines as a Collection. - * @todo #615:30min Remove this method, it is not needed anymore. - */ - @Deprecated - Collection original(); - /** * Fetch the next YamlNode. * @param prev Previous YamlLine - line before the node start. diff --git a/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java b/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java index a9b4b5f7..7bfea42f 100644 --- a/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java @@ -33,7 +33,6 @@ import org.mockito.Mockito; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -45,20 +44,6 @@ */ public final class BackwardsTest { - /** - * Backwards delegates the call to originals(). - */ - @Test - public void delegatesOriginals() { - final YamlLines initial = Mockito.mock(YamlLines.class); - final Collection lines = Mockito.mock(Collection.class); - Mockito.when(initial.original()).thenReturn(lines); - MatcherAssert.assertThat( - new Backwards(initial).original(), - Matchers.is(lines) - ); - } - /** * Backwards delegates the call to toYamlNode(). */ diff --git a/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java b/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java index 4808c865..02a40c09 100644 --- a/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java @@ -33,7 +33,6 @@ import org.mockito.Mockito; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -44,19 +43,6 @@ * @since 4.2.0 */ public final class FirstCommentFoundTest { - /** - * FirstCommentFound delegates the call to originals(). - */ - @Test - public void delegatesOriginals() { - final YamlLines initial = Mockito.mock(YamlLines.class); - final Collection lines = Mockito.mock(Collection.class); - Mockito.when(initial.original()).thenReturn(lines); - MatcherAssert.assertThat( - new FirstCommentFound(initial).original(), - Matchers.is(lines) - ); - } /** * FirstCommentFound delegates the call to toYamlNode(). diff --git a/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java b/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java index b4b83254..a62a80e8 100644 --- a/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java +++ b/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java @@ -42,27 +42,6 @@ * @since 3.0.2 */ public final class SameIndentationLevelTestCase { - - /** - * SameIndentationLevel should return all the lines - * that it encapsulates. - */ - @Test - public void fetchesTheLines() { - final List lines = new ArrayList<>(); - lines.add(new RtYamlLine("first: somethingElse", 0)); - lines.add(new RtYamlLine("second: ", 1)); - lines.add(new RtYamlLine(" fourth: some", 2)); - lines.add(new RtYamlLine(" fifth: values", 3)); - lines.add(new RtYamlLine("third: something", 4)); - final YamlLines yaml = new SameIndentationLevel( - new AllYamlLines(lines) - ); - MatcherAssert.assertThat( - yaml.original().size(), - Matchers.equalTo(lines.size()) - ); - } /** * SameIndentationLevel should iterate only over the lines, diff --git a/src/test/java/com/amihaiemil/eoyaml/SkipTest.java b/src/test/java/com/amihaiemil/eoyaml/SkipTest.java index e91bba5f..6bec7012 100644 --- a/src/test/java/com/amihaiemil/eoyaml/SkipTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/SkipTest.java @@ -33,7 +33,6 @@ import org.mockito.Mockito; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -145,20 +144,6 @@ public void skipsNoLines() { ); } - /** - * Skip delegates the call to originals(). - */ - @Test - public void delegatesOriginals() { - final YamlLines initial = Mockito.mock(YamlLines.class); - final Collection lines = Mockito.mock(Collection.class); - Mockito.when(initial.original()).thenReturn(lines); - MatcherAssert.assertThat( - new Skip(initial).original(), - Matchers.is(lines) - ); - } - /** * Skip delegates the call to toYamlNode(). */ diff --git a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java index 15f4e5b7..d9039964 100644 --- a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java @@ -33,7 +33,6 @@ import org.mockito.Mockito; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -45,21 +44,6 @@ */ public final class StartMarkersTest { - /** - * StartMarkers can return the encapsulated lines. - */ - @Test - @SuppressWarnings("unchecked") - public void returnsLines() { - final YamlLines lines = Mockito.mock(YamlLines.class); - final Collection collection = Mockito.mock(Collection.class); - Mockito.when(lines.original()).thenReturn(collection); - MatcherAssert.assertThat( - new StartMarkers(lines).original(), - Matchers.is(collection) - ); - } - /** * StartMarkers can turn itself into YamlNode. */ diff --git a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java index 8bd3d7d2..6f351809 100644 --- a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java @@ -29,7 +29,6 @@ import com.amihaiemil.eoyaml.exceptions.YamlIndentationException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.hamcrest.MatcherAssert; @@ -47,21 +46,6 @@ */ public final class WellIndentedTest { - /** - * WellIndented can return the encapsulated lines. - */ - @Test - @SuppressWarnings("unchecked") - public void returnsLines() { - final YamlLines lines = Mockito.mock(YamlLines.class); - final Collection collection = Mockito.mock(Collection.class); - Mockito.when(lines.original()).thenReturn(collection); - MatcherAssert.assertThat( - new WellIndented(lines).original(), - Matchers.is(collection) - ); - } - /** * WellIndented can turn itself into YamlNode. */