File tree Expand file tree Collapse file tree
main/java/com/gooddata/collections
test/java/com/gooddata/collections Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,15 +236,15 @@ public boolean equals(final Object o) {
236236 final PageableList <?> that = (PageableList <?>) o ;
237237
238238 if (!items .equals (that .items )) return false ;
239- if (! getPaging ().equals (that .getPaging ())) return false ;
240- return getLinks ().equals (that .getLinks ());
239+ if (getPaging () != null ? ! getPaging ().equals (that .getPaging ()) : that . getPaging () != null ) return false ;
240+ return getLinks () != null ? getLinks () .equals (that .getLinks ()) : that . getLinks () == null ;
241241 }
242242
243243 @ Override
244244 public int hashCode () {
245245 int result = items .hashCode ();
246- result = 31 * result + getPaging ().hashCode ();
247- result = 31 * result + getLinks ().hashCode ();
246+ result = 31 * result + ( getPaging () != null ? getPaging () .hashCode () : 0 );
247+ result = 31 * result + ( getLinks () != null ? getLinks () .hashCode () : 0 );
248248 return result ;
249249 }
250250}
Original file line number Diff line number Diff line change 77
88import org .testng .annotations .Test ;
99
10+ import java .util .Collections ;
11+
1012import static java .util .Arrays .asList ;
1113import static org .hamcrest .CoreMatchers .notNullValue ;
1214import static org .hamcrest .CoreMatchers .nullValue ;
1315import static org .hamcrest .MatcherAssert .assertThat ;
1416import static org .hamcrest .Matchers .empty ;
1517import static org .hamcrest .Matchers .hasSize ;
1618import static org .hamcrest .core .Is .is ;
19+ import static org .hamcrest .core .IsNot .not ;
1720
1821public class PageableListTest {
1922
@@ -41,4 +44,18 @@ public void testCollectionWithPaging() {
4144 assertThat (collection .getNextPage (), notNullValue ());
4245 assertThat (collection .getNextPage ().getPageUri (null ).toString (), is ("next" ));
4346 }
47+
48+ @ Test
49+ public void testEquals () {
50+ assertThat (new PageableList <>(), is (new PageableList <>()));
51+ assertThat (new PageableList <>(Collections .singletonList (1 ), null ), is (not (new PageableList <>())));
52+ }
53+
54+
55+ @ Test
56+ public void testHashCode () {
57+ assertThat (new PageableList <>().hashCode (), is (new PageableList <>().hashCode ()));
58+ assertThat (new PageableList <>(Collections .singletonList (1 ), null ).hashCode (), is (not (new PageableList <>().hashCode ())));
59+ }
60+
4461}
You can’t perform that action at this time.
0 commit comments