3333import java .util .Iterator ;
3434import java .util .List ;
3535import java .util .ListIterator ;
36+ import java .util .Objects ;
37+
3638import javafx .beans .InvalidationListener ;
3739import javafx .collections .ListChangeListener ;
3840import javafx .collections .ObservableList ;
@@ -110,6 +112,7 @@ public boolean setAll(E... elements) {
110112
111113 @ Override
112114 public boolean setAll (Collection <? extends E > col ) {
115+ Objects .requireNonNull (col );
113116 onProposedChange (Collections .unmodifiableList (new ArrayList <>(col )), 0 , size ());
114117 try {
115118 modCount ++;
@@ -161,6 +164,7 @@ public boolean retainAll(E... elements) {
161164
162165 @ Override
163166 public void remove (int from , int to ) {
167+ Objects .checkFromToIndex (from , to , size ());
164168 onProposedChange (Collections .<E >emptyList (), from , to );
165169 try {
166170 modCount ++;
@@ -230,6 +234,7 @@ public boolean containsAll(Collection<?> c) {
230234
231235 @ Override
232236 public boolean addAll (Collection <? extends E > c ) {
237+ Objects .requireNonNull (c );
233238 onProposedChange (Collections .unmodifiableList (new ArrayList <>(c )), size (), size ());
234239 try {
235240 modCount ++;
@@ -245,6 +250,8 @@ public boolean addAll(Collection<? extends E> c) {
245250
246251 @ Override
247252 public boolean addAll (int index , Collection <? extends E > c ) {
253+ Objects .requireNonNull (c );
254+ Objects .checkIndex (index , size () + 1 );
248255 onProposedChange (Collections .unmodifiableList (new ArrayList <>(c )), index , index );
249256 try {
250257 modCount ++;
@@ -260,6 +267,7 @@ public boolean addAll(int index, Collection<? extends E> c) {
260267
261268 @ Override
262269 public boolean removeAll (Collection <?> c ) {
270+ Objects .requireNonNull (c );
263271 removeFromList (this , 0 , c , false );
264272 try {
265273 modCount ++;
@@ -275,6 +283,7 @@ public boolean removeAll(Collection<?> c) {
275283
276284 @ Override
277285 public boolean retainAll (Collection <?> c ) {
286+ Objects .requireNonNull (c );
278287 removeFromList (this , 0 , c , true );
279288 try {
280289 modCount ++;
@@ -313,6 +322,7 @@ public E set(int index, E element) {
313322
314323 @ Override
315324 public void add (int index , E element ) {
325+ Objects .checkIndex (index , size () + 1 );
316326 onProposedChange (Collections .singletonList (element ), index , index );
317327 try {
318328 modCount ++;
@@ -325,6 +335,7 @@ public void add(int index, E element) {
325335
326336 @ Override
327337 public E remove (int index ) {
338+ Objects .checkIndex (index , size ());
328339 onProposedChange (Collections .<E >emptyList (), index , index + 1 );
329340 try {
330341 modCount ++;
@@ -460,6 +471,7 @@ public boolean containsAll(Collection<?> c) {
460471
461472 @ Override
462473 public boolean addAll (Collection <? extends E > c ) {
474+ Objects .requireNonNull (c );
463475 checkForComodification ();
464476 onProposedChange (Collections .unmodifiableList (new ArrayList <>(c )), offset + size (), offset + size ());
465477 try {
@@ -476,6 +488,8 @@ public boolean addAll(Collection<? extends E> c) {
476488
477489 @ Override
478490 public boolean addAll (int index , Collection <? extends E > c ) {
491+ Objects .requireNonNull (c );
492+ Objects .checkIndex (index , size () + 1 );
479493 checkForComodification ();
480494 onProposedChange (Collections .unmodifiableList (new ArrayList <>(c )), offset + index , offset + index );
481495 try {
@@ -492,6 +506,7 @@ public boolean addAll(int index, Collection<? extends E> c) {
492506
493507 @ Override
494508 public boolean removeAll (Collection <?> c ) {
509+ Objects .requireNonNull (c );
495510 checkForComodification ();
496511 removeFromList (this , offset , c , false );
497512 try {
@@ -508,6 +523,7 @@ public boolean removeAll(Collection<?> c) {
508523
509524 @ Override
510525 public boolean retainAll (Collection <?> c ) {
526+ Objects .requireNonNull (c );
511527 checkForComodification ();
512528 removeFromList (this , offset , c , true );
513529 try {
@@ -550,6 +566,7 @@ public E set(int index, E element) {
550566
551567 @ Override
552568 public void add (int index , E element ) {
569+ Objects .checkIndex (index , size () + 1 );
553570 checkForComodification ();
554571 onProposedChange (Collections .singletonList (element ), offset + index , offset + index );
555572 try {
@@ -563,6 +580,7 @@ public void add(int index, E element) {
563580
564581 @ Override
565582 public E remove (int index ) {
583+ Objects .checkIndex (index , size ());
566584 checkForComodification ();
567585 onProposedChange (Collections .<E >emptyList (), offset + index , offset + index + 1 );
568586 try {
0 commit comments