Collections contains static methods which operate on Collection classes. @since 1.2
| 28 | * @since 1.2 |
| 29 | */ |
| 30 | public class Collections { |
| 31 | |
| 32 | private static final class CopiesList<E> extends AbstractList<E> implements |
| 33 | Serializable { |
| 34 | private static final long serialVersionUID = 2739099268398711800L; |
| 35 | |
| 36 | private final int n; |
| 37 | |
| 38 | private final E element; |
| 39 | |
| 40 | CopiesList(int length, E object) { |
| 41 | if (length < 0) { |
| 42 | throw new IllegalArgumentException(); |
| 43 | } |
| 44 | n = length; |
| 45 | element = object; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean contains(Object object) { |
| 50 | return element == null ? object == null : element.equals(object); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public int size() { |
| 55 | return n; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public E get(int location) { |
| 60 | if (0 <= location && location < n) { |
| 61 | return element; |
| 62 | } |
| 63 | throw new IndexOutOfBoundsException(); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | @SuppressWarnings("unchecked") |
| 68 | private static final class EmptyList extends AbstractList implements |
| 69 | RandomAccess, Serializable { |
| 70 | private static final long serialVersionUID = 8842843931221139166L; |
| 71 | |
| 72 | @Override |
| 73 | public boolean contains(Object object) { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public int size() { |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public Object get(int location) { |
| 84 | throw new IndexOutOfBoundsException(); |
| 85 | } |
| 86 | |
| 87 | private Object readResolve() { |
nothing calls this directly
no outgoing calls
no test coverage detected