-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayListOnSteroids.java
49 lines (40 loc) · 1015 Bytes
/
ArrayListOnSteroids.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ag.datastrs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Adding some functionality I like to use, but are missing from
* ArrayList implementation.
* @author agoyal
*
* @param <E>
*/
public class ArrayListOnSteroids<E> extends ArrayList<E> implements List<E>{
private static final long serialVersionUID = 1L;
public ArrayListOnSteroids() {
super();
}
/**
* Copy Constructor
* @param c
*/
public ArrayListOnSteroids(Collection<? extends E> c) {
super(c);
}
public ArrayListOnSteroids<E> addItem(E item) {
add(item);
return this;
}
public ArrayListOnSteroids<E> addItems(Collection<? extends E> c) {
addAll(c);
return this;
}
public ArrayListOnSteroids<E> and(E item) {
add(item);
return this;
}
public ArrayListOnSteroids<E> removeItem(E item) {
remove(item);
return this;
}
}