Repository: decorators-squad/eo-yaml (java)

Issue:
Rename YamlLines.lines()
This method should be renamed to ``original()`` as in "return the original, unaltered, collection of underlying lines"

Pull request:
#284 YamlLines.lines() -> YamlLines.original()
Fixes #284 

Patch:
diff --git a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
index ac29f2e..1bff40a 100644
--- a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
+++ b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
@@ -67,7 +67,7 @@ final class AllYamlLines implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
+    public Collection<YamlLine> original() {
         return this.lines;
     }
 
@@ -114,7 +114,7 @@ final class AllYamlLines implements YamlLines {
             node = new ReadYamlSequence(prev, this);
         } else if (first.trimmed().contains(":")){
             node = new ReadYamlMapping(prev, this);
-        } else if(this.lines().size() == 1) {
+        } else if(this.original().size() == 1) {
             node = new ReadPlainScalar(first);
         } else {
             throw new YamlReadingException(
diff --git a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
index 551e30e..f4d667a 100644
--- a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
+++ b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
@@ -91,8 +91,8 @@ final class GreaterIndentation implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
-        return this.yamlLines.lines();
+    public Collection<YamlLine> original() {
+        return this.yamlLines.original();
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
index 54d65c3..6872c52 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
@@ -75,7 +75,7 @@ final class ReadYamlStream extends BaseYamlStream {
         final List<YamlNode> values = new ArrayList<>();
         for(final YamlLine startDoc : this.startMarkers) {
             final YamlLines document = this.readDocument(startDoc);
-            if(!document.lines().isEmpty()) {
+            if(!document.original().isEmpty()) {
                 values.add(document.toYamlNode(startDoc));
             }
         }
@@ -93,7 +93,7 @@ final class ReadYamlStream extends BaseYamlStream {
         if(!"---".equals(startLine.trimmed())) {
             yamlDocLines.add(startLine);
         }
-        for(final YamlLine line : this.all.lines()) {
+        for(final YamlLine line : this.all.original()) {
             if(line.number() > start.number()) {
                 final String current = line.trimmed();
                 if("---".equals(current) || "...".equals(current)) {
diff --git a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
index a0c0830..497093c 100644
--- a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
+++ b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
@@ -90,8 +90,8 @@ final class SameIndentationLevel implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
-        return this.yamlLines.lines();
+    public Collection<YamlLine> original() {
+        return this.yamlLines.original();
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/Skip.java b/src/main/java/com/amihaiemil/eoyaml/Skip.java
index b892131..35ec6b8 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Skip.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Skip.java
@@ -86,8 +86,8 @@ final class Skip implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
-        return this.yamlLines.lines();
+    public Collection<YamlLine> original() {
+        return this.yamlLines.original();
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
index 70a8340..386e4cb 100644
--- a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
+++ b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
@@ -98,8 +98,8 @@ final class StartMarkers implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
-        return this.yamlLines.lines();
+    public Collection<YamlLine> original() {
+        return this.yamlLines.original();
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
index 73b8bf6..c738ec8 100644
--- a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
+++ b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
@@ -131,8 +131,8 @@ final class WellIndented implements YamlLines {
     }
 
     @Override
-    public Collection<YamlLine> lines() {
-        return this.yamlLines.lines();
+    public Collection<YamlLine> original() {
+        return this.yamlLines.original();
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
index bd99ac9..bf79eb5 100644
--- a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
+++ b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
@@ -39,12 +39,13 @@ import java.util.Iterator;
 interface YamlLines extends Iterable<YamlLine> {
 
     /**
-     * All the YAML lines, as a collection.<br>
-     * This method should always return all the lines
-     * there are, irrespective of iteration logic!
-     * @return These YamlLines as a Collection.
+     * 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.
      */
-    Collection<YamlLine> lines();
+    Collection<YamlLine> original();
 
     /**
      * Turn these lines into a YamlNode.
@@ -59,7 +60,7 @@ interface YamlLines extends Iterable<YamlLine> {
      * @return Iterator of YamlLine.
      */
     default Iterator<YamlLine> iterator() {
-        return this.lines().iterator();
+        return this.original().iterator();
     }
 
     /**
@@ -69,7 +70,7 @@ interface YamlLines extends Iterable<YamlLine> {
      * @return YamlLine or throws {@link IndexOutOfBoundsException}.
      */
     default YamlLine line(final int number) {
-        final Collection<YamlLine> lines = this.lines();
+        final Collection<YamlLine> lines = this.original();
         if(number < 0 && lines.size() > 0) {
             return lines.iterator().next();
         }
@@ -81,7 +82,7 @@ interface YamlLines extends Iterable<YamlLine> {
         throw new IllegalArgumentException(
             "Couldn't find line " + number
           + ". Pay attention, there are "
-          + this.lines().size() + " lines!");
+          + this.original().size() + " lines!");
     }
 
 }


Test patch:
diff --git a/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java b/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java
index 287fec6..b7ef373 100644
--- a/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java
+++ b/src/test/java/com/amihaiemil/eoyaml/SameIndentationLevelTestCase.java
@@ -59,7 +59,7 @@ public final class SameIndentationLevelTestCase {
             new AllYamlLines(lines)
         );
         MatcherAssert.assertThat(
-            yaml.lines().size(),
+            yaml.original().size(),
             Matchers.equalTo(lines.size())
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
index fe1b9e0..c7e2009 100644
--- a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
@@ -53,9 +53,9 @@ public final class StartMarkersTest {
     public void returnsLines() {
         final YamlLines lines = Mockito.mock(YamlLines.class);
         final Collection<YamlLine> collection = Mockito.mock(Collection.class);
-        Mockito.when(lines.lines()).thenReturn(collection);
+        Mockito.when(lines.original()).thenReturn(collection);
         MatcherAssert.assertThat(
-            new StartMarkers(lines).lines(),
+            new StartMarkers(lines).original(),
             Matchers.is(collection)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
index 448e1a3..9d61a6d 100644
--- a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
@@ -55,9 +55,9 @@ public final class WellIndentedTest {
     public void returnsLines() {
         final YamlLines lines = Mockito.mock(YamlLines.class);
         final Collection<YamlLine> collection = Mockito.mock(Collection.class);
-        Mockito.when(lines.lines()).thenReturn(collection);
+        Mockito.when(lines.original()).thenReturn(collection);
         MatcherAssert.assertThat(
-            new WellIndented(lines).lines(),
+            new WellIndented(lines).original(),
             Matchers.is(collection)
         );
     }