Skip to content

Commit

Permalink
Add a method to check if the range consists of a single line only.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Oct 1, 2023
1 parent 6196671 commit 20a50bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/main/java/edu/hm/hafner/util/LineRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public int getEnd() {
return end;
}

/**
* Returns whether this range is just a single line.
*
* @return {@code true} if this range is just a single line, {@code false} otherwise
*/
public boolean isSingleLine() {
return start == end;
}

@Override
public boolean equals(@CheckForNull final Object obj) {
if (this == obj) {
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/edu/hm/hafner/util/LineRangeListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.junit.jupiter.api.Test;

import nl.jqno.equalsverifier.EqualsVerifier;

import static org.assertj.core.api.Assertions.*;

/**
Expand Down Expand Up @@ -105,9 +103,4 @@ private LineRangeList createThreeElements() {
assertThat(range).containsExactly(new LineRange(0, 1), new LineRange(2, 3), new LineRange(4, 5));
return range;
}

@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple().forClass(LineRange.class).verify();
}
}

0 comments on commit 20a50bc

Please sign in to comment.