99import java .util .ArrayList ;
1010import java .util .Collection ;
1111import java .util .List ;
12+ import javax .annotation .Nonnull ;
1213
1314public class SizeLimitingPyList extends PyList implements PyWrapper {
1415 private int maxSize ;
@@ -20,6 +21,9 @@ private SizeLimitingPyList(List<Object> list) {
2021
2122 public SizeLimitingPyList (List <Object > list , int maxSize ) {
2223 super (list );
24+ if (list == null ) {
25+ throw new IllegalArgumentException ("list is null" );
26+ }
2327 if (maxSize <= 0 ) {
2428 throw new IllegalArgumentException ("maxSize must be >= 1" );
2529 }
@@ -31,25 +35,31 @@ public SizeLimitingPyList(List<Object> list, int maxSize) {
3135 }
3236
3337 @ Override
34- public boolean add (Object element ) {
38+ public boolean add (@ Nonnull Object element ) {
3539 checkSize (size () + 1 );
3640 return super .add (element );
3741 }
3842
3943 @ Override
40- public void add (int index , Object element ) {
44+ public void add (int index , @ Nonnull Object element ) {
4145 checkSize (size () + 1 );
4246 super .add (index , element );
4347 }
4448
4549 @ Override
46- public boolean addAll (int index , Collection <?> elements ) {
50+ public boolean addAll (int index , @ Nonnull Collection <?> elements ) {
51+ if (elements == null || elements .isEmpty ()) {
52+ return false ;
53+ }
4754 checkSize (size () + elements .size ());
4855 return super .addAll (index , elements );
4956 }
5057
5158 @ Override
52- public boolean addAll (Collection <?> elements ) {
59+ public boolean addAll (@ Nonnull Collection <?> elements ) {
60+ if (elements == null || elements .isEmpty ()) {
61+ return false ;
62+ }
5363 checkSize (size () + elements .size ());
5464 return super .addAll (elements );
5565 }
0 commit comments