1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.commons.collections.primitives.adapters; |
18 | |
|
19 | |
import java.util.Collection; |
20 | |
|
21 | |
import org.apache.commons.collections.primitives.BooleanIterator; |
22 | |
import org.apache.commons.collections.primitives.BooleanCollection; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
abstract class AbstractCollectionBooleanCollection |
30 | |
implements BooleanCollection { |
31 | |
|
32 | 284 | protected AbstractCollectionBooleanCollection() { |
33 | 284 | } |
34 | |
|
35 | |
public boolean add(boolean element) { |
36 | 0 | return getCollection().add(new Boolean(element)); |
37 | |
} |
38 | |
|
39 | |
public boolean addAll(BooleanCollection c) { |
40 | 0 | return getCollection().addAll(BooleanCollectionCollection.wrap(c)); |
41 | |
} |
42 | |
|
43 | |
public void clear() { |
44 | 0 | getCollection().clear(); |
45 | 0 | } |
46 | |
|
47 | |
public boolean contains(boolean element) { |
48 | 0 | return getCollection().contains(new Boolean(element)); |
49 | |
} |
50 | |
|
51 | |
public boolean containsAll(BooleanCollection c) { |
52 | 0 | return getCollection().containsAll( |
53 | |
BooleanCollectionCollection.wrap(c)); |
54 | |
} |
55 | |
|
56 | |
public String toString() { |
57 | 0 | return getCollection().toString(); |
58 | |
} |
59 | |
|
60 | |
public boolean isEmpty() { |
61 | 0 | return getCollection().isEmpty(); |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
public BooleanIterator iterator() { |
70 | 284 | return IteratorBooleanIterator.wrap(getCollection().iterator()); |
71 | |
} |
72 | |
|
73 | |
public boolean removeElement(boolean element) { |
74 | 0 | return getCollection().remove(new Boolean(element)); |
75 | |
} |
76 | |
|
77 | |
public boolean removeAll(BooleanCollection c) { |
78 | 0 | return getCollection().removeAll(BooleanCollectionCollection.wrap(c)); |
79 | |
} |
80 | |
|
81 | |
public boolean retainAll(BooleanCollection c) { |
82 | 0 | return getCollection().retainAll(BooleanCollectionCollection.wrap(c)); |
83 | |
} |
84 | |
|
85 | |
public int size() { |
86 | 787 | return getCollection().size(); |
87 | |
} |
88 | |
|
89 | |
public boolean[] toArray() { |
90 | 0 | Object[] src = getCollection().toArray(); |
91 | 0 | boolean[] dest = new boolean[src.length]; |
92 | 0 | for(int i=0;i<src.length;i++) { |
93 | 0 | dest[i] = ((Boolean)(src[i])).booleanValue(); |
94 | |
} |
95 | 0 | return dest; |
96 | |
} |
97 | |
|
98 | |
public boolean[] toArray(boolean[] dest) { |
99 | 0 | Object[] src = getCollection().toArray(); |
100 | 0 | if(dest.length < src.length) { |
101 | 0 | dest = new boolean[src.length]; |
102 | |
} |
103 | 0 | for(int i=0;i<src.length;i++) { |
104 | 0 | dest[i] = ((Boolean)(src[i])).booleanValue(); |
105 | |
} |
106 | 0 | return dest; |
107 | |
} |
108 | |
|
109 | |
protected abstract Collection getCollection(); |
110 | |
|
111 | |
} |