Add equals/hashCode support for Unpaged.

Closes #3061
This commit is contained in:
Mark Paluch
2024-03-12 13:56:14 +01:00
parent aec8f1a45a
commit ce368882f4
2 changed files with 22 additions and 0 deletions

View File

@@ -89,4 +89,21 @@ final class Unpaged implements Pageable {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Unpaged unpaged)) {
return false;
}
return sort.equals(unpaged.sort);
}
@Override
public int hashCode() {
return sort.hashCode();
}
}

View File

@@ -58,6 +58,11 @@ class PageRequestUnitTests extends AbstractPageRequestUnitTests {
// Is not equal to instance with another sort
assertNotEqualsAndHashcode(request, PageRequest.of(1, 10, Direction.ASC, "foo"));
// Equaliity for unpaged
assertEqualsAndHashcode(Pageable.unpaged(), Pageable.unpaged(Sort.unsorted()));
assertNotEqualsAndHashcode(Pageable.unpaged(), Pageable.unpaged(Sort.by("foo")));
}
@Test // DATACMNS-1581