Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/org/springframework/data/domain/PageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @param <T> the type of which the page consists.
* @author Oliver Gierke
* @author Mark Paluch
* @author Manousos Mathioudakis
*/
public class PageImpl<T> extends Chunk<T> implements Page<T> {

Expand Down Expand Up @@ -120,7 +121,8 @@ public String toString() {
contentType = content.get(0).getClass().getName();
}

return String.format("Page %s of %d containing %s instances", getNumber() + 1, getTotalPages(), contentType);
return String.format("Page %s of %d containing %s instances @%s",
getNumber() + 1, getTotalPages(), contentType, Integer.toHexString(hashCode()));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*
* @author Oliver Gierke
* @author Mark Paluch
* @author Manousos Mathioudakis
*/
class PageImplUnitTests {

Expand Down Expand Up @@ -191,7 +192,16 @@ void toStringShouldNotInspectNullInstances() {

Page<Integer> page = new PageImpl<>(Collections.singletonList(null));

assertThat(page).hasToString("Page 1 of 1 containing UNKNOWN instances");
assertThat(page).hasToString(String.format("Page 1 of 1 containing UNKNOWN instances @%s", Integer.toHexString(page.hashCode())));
}

@Test //issue 2066
void toStringShouldNotBeEqualsForDifferentPages() {
Page<String> page1 = new PageImpl<>(Arrays.asList("item1", "item2"), PageRequest.of(0, 5), 10);
Page<String> page2 = new PageImpl<>(Arrays.asList("item1", "item3"), PageRequest.of(0, 5), 10);

assertThat(page1.toString()).isNotEqualTo(page2.toString());
}


}