MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / Collections

Class Collections

Ports/CLDC11/src/java/util/Collections.java:27–3112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected