Skip to content

Commit

Permalink
Implemented nested() method
Browse files Browse the repository at this point in the history
  • Loading branch information
SherifWaly committed Feb 17, 2017
1 parent 50fbb05 commit baaf99d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/amihaiemil/camel/RtYamlLines.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* YamlLines default implementation.
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id: aa086c8b637f198e26bc2ab0550fff6763e30016 $
* @version $Id$
* @since 1.0.0
*/
final class RtYamlLines implements YamlLines {
Expand Down Expand Up @@ -54,19 +54,17 @@ public Iterator<YamlLine> iterator() {
public YamlLines nested(final int after) {
final List<YamlLine> nestedLines = new ArrayList<YamlLine>();
YamlLine start = null;
int index = 0;
for(final YamlLine line: this.lines) {
if(index == after) {
if(line.number() == after) {
start = line;
}
if(index > after) {
if(line.number() > after) {
if(line.indentation() > start.indentation()) {
nestedLines.add(line);
} else {
break;
}
}
index++;
}
return new RtYamlLines(nestedLines);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/amihaiemil/camel/RtYamlLinesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**
* Unit tests for {@link RtYamlLines}.
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id: 9009d046234339ba4ef3974ddf83b83c8134c3ad $
* @version $Id$
* @sinve 1.0.0
*/
public final class RtYamlLinesTest {
Expand Down

0 comments on commit baaf99d

Please sign in to comment.