Skip to content

Commit bf7302e

Browse files
Apply review feedback
1 parent df9c883 commit bf7302e

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

utils/src/main/java/org/opentripplanner/utils/collection/IndexedListElement.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.opentripplanner.utils.collection;
22

33
import java.util.Objects;
4+
import org.opentripplanner.utils.tostring.ValueObjectToStringBuilder;
45

56
/**
67
* A small container for an element and its index in a list.
@@ -39,4 +40,15 @@ public boolean equals(Object obj) {
3940
public int hashCode() {
4041
return Objects.hash(index, element);
4142
}
43+
44+
@Override
45+
public String toString() {
46+
return ValueObjectToStringBuilder.of()
47+
.addText("[")
48+
.addNum(index)
49+
.addText("=")
50+
.addObj(element)
51+
.addText("]")
52+
.toString();
53+
}
4254
}

utils/src/test/java/org/opentripplanner/utils/collection/ListUtilsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,7 @@ void indexedList() {
138138
),
139139
indexed
140140
);
141+
142+
assertEquals("[0=A]", indexed.getFirst().toString());
141143
}
142144
}

utils/src/test/java/org/opentripplanner/utils/collection/StreamUtilsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
class StreamUtilsTest {
99

1010
@Test
11-
void nullable() {
11+
void nullableCollection() {
1212
assertEquals(List.of(), StreamUtils.ofNullableCollection(null).toList());
1313
}
1414

1515
@Test
16-
void emptyList() {
16+
void nullableCollectionEmptyList() {
1717
assertEquals(List.of(), StreamUtils.ofNullableCollection(List.of()).toList());
1818
}
1919

2020
@Test
21-
void oneElement() {
21+
void nullableCollectionOneElement() {
2222
assertEquals(List.of(1), StreamUtils.ofNullableCollection(List.of(1)).toList());
2323
}
2424

2525
@Test
26-
void twoElements() {
26+
void nullableCollectionTwoElements() {
2727
assertEquals(List.of(1, 2), StreamUtils.ofNullableCollection(List.of(1, 2)).toList());
2828
}
2929
}

0 commit comments

Comments
 (0)