public abstract class AbstractBooleanCollection extends AbstractPrimitiveCollectable<Boolean> implements BooleanCollection
boolean
elements.
This class implements Collection
allowing
seamless integration with other APIs.
The iterator
and size
must be implemented by subclases.
To make the subclass modifiable, the add(boolean)
and
iterator remove()
methods must also be implemented.
Subclasses may override other methods to increase efficiency.
Modifier | Constructor and Description |
---|---|
protected |
AbstractBooleanCollection()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(boolean value)
Adds a primitive value to this collection (optional operation).
|
boolean |
add(Boolean value)
Adds the
Boolean value to this collection (optional operation). |
boolean |
addAll(boolean[] values)
Adds an array of primitive values to this collection (optional operation).
|
boolean |
addAll(BooleanCollection values)
Adds a collection of primitive values to this collection (optional operation).
|
boolean |
addAll(Collection<? extends Boolean> coll)
Adds a collection of
Boolean values to this collection (optional operation). |
protected void |
arrayCopy(int fromIndex,
boolean[] dest,
int destIndex,
int size)
Copies data from this collection into the specified array.
|
protected void |
checkAddModifiable()
Check whether add is suported and throw an exception.
|
protected void |
checkRemoveModifiable()
Check whether remove is suported and throw an exception.
|
void |
clear()
Clears the collection/map of all elements (optional operation).
|
boolean |
contains(boolean value)
Checks whether this collection contains a specified primitive value.
|
boolean |
contains(Object value)
Checks whether this collection contains a specified
Boolean value. |
boolean |
containsAll(boolean[] values)
Checks if this collection contains all of the values in the specified array.
|
boolean |
containsAll(BooleanCollection values)
Checks if this collection contains all of the values in the specified collection.
|
boolean |
containsAll(Collection<?> coll)
Checks if the collection contains all of the primitive values.
|
boolean |
containsAny(boolean[] values)
Checks if this collection contains any of the values in the specified array.
|
boolean |
containsAny(BooleanCollection values)
Checks if this collection contains any of the values in the specified collection.
|
boolean |
containsAny(Collection<?> coll)
Checks if the collection contains any of the primitive values in the array.
|
protected boolean |
isAddModifiable()
Are the add methods supported.
|
boolean |
isModifiable()
Is the collection modifiable in any way.
|
protected boolean |
isRemoveModifiable()
Are the remove methods supported.
|
protected boolean |
isToPrimitivePossible(Object value)
Checks if the object can be converted to a primitive successfully.
|
boolean |
remove(Object value)
Removes the first occurrance of the specified
Boolean value from
this collection (optional operation). |
boolean |
removeAll(boolean value)
Removes all occurrences of the specified primitive value from this collection.
|
boolean |
removeAll(boolean[] values)
Removes all occurrences from this collection of each primitive in the specified array.
|
boolean |
removeAll(BooleanCollection values)
Removes all occurrences from this collection of each primitive in the specified collection.
|
boolean |
removeAll(Collection<?> coll)
Removes each of a collection of
Boolean values from this collection (optional operation). |
boolean |
removeFirst(boolean value)
Removes the first occurrence of the specified primitive value from this collection
|
boolean |
retainAll(boolean[] values)
Retains each element of this collection that is present in the specified array
removing all other values.
|
boolean |
retainAll(BooleanCollection values)
Retains each element of this collection that is present in the specified collection
removing all other values.
|
boolean |
retainAll(Collection<?> coll)
Retains each of a collection of
Boolean values, removing other
values (optional operation). |
Object[] |
toArray()
Gets the collection as an array of
Boolean . |
<T> T[] |
toArray(T[] array)
Gets the collection as an array, using the array provided.
|
boolean[] |
toBooleanArray()
Gets the elements of this collection as an array.
|
boolean[] |
toBooleanArray(boolean[] array,
int startIndex)
Copies the elements of this collection into an array at a specified position.
|
protected Boolean |
toObject(boolean value)
Wraps an
boolean with an Object wrapper. |
protected boolean |
toPrimitive(Object value)
Unwraps the
Boolean to retrieve the primitive boolean . |
protected boolean[] |
toPrimitiveArray(Collection<?> coll)
Unwraps a
Collection to retrieve the primitive boolean . |
String |
toString()
Gets a string representing this collection.
|
clone, isEmpty, optimize
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
iterator
clone, isEmpty, optimize, size
equals, hashCode, isEmpty, size
protected AbstractBooleanCollection()
public boolean contains(boolean value)
This implementation uses booleanIterator()
.
contains
in interface BooleanCollection
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(boolean[] values)
true
is returned.
This implementation uses contains(boolean)
.
containsAll
in interface BooleanCollection
values
- the values to search for, null treated as empty arraytrue
if all of the values are foundpublic boolean containsAll(BooleanCollection values)
true
is returned.
This implementation uses contains(boolean)
.
containsAll
in interface BooleanCollection
values
- the values to search for, null treated as empty collectiontrue
if all of the values are foundpublic boolean containsAny(boolean[] values)
false
is returned.
This implementation uses contains(boolean)
.
containsAny
in interface BooleanCollection
values
- the values to search for, null treated as empty arraytrue
if at least one of the values is foundpublic boolean containsAny(BooleanCollection values)
false
is returned.
This implementation uses contains(boolean)
.
containsAny
in interface BooleanCollection
values
- the values to search for, null treated as empty collectiontrue
if at least one of the values is foundpublic boolean[] toBooleanArray()
This implementation uses arrayCopy
.
toBooleanArray
in interface BooleanCollection
public boolean[] toBooleanArray(boolean[] array, int startIndex)
If the array specified is null a new array is created. If the array specified is large enough, it will be modified. If the array is not large enough, a new array will be created containing the values from the specified array before the startIndex plus those from this collection.
This implementation uses arrayCopy
.
toBooleanArray
in interface BooleanCollection
array
- the array to add the elements to, null treated as empty arraystartIndex
- the position in the array to start setting elementsIndexOutOfBoundsException
- if the index is negativepublic void clear()
The collection/map will have a zero size after this method completes. This method is optional, throwing an UnsupportedOperationException if the collection/map cannot be cleared.
This implementation uses iterator()
.
clear
in interface Collection<Boolean>
clear
in interface PrimitiveCollectable<Boolean>
UnsupportedOperationException
- if method not supported by this collectionpublic boolean add(boolean value)
This implementation throws UnsupportedOperationException.
add
in interface BooleanCollection
value
- the value to add to this collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(boolean[] values)
This implementation uses add(boolean)
.
addAll
in interface BooleanCollection
values
- the values to add to this collection, null treated as empty arraytrue
if this collection was modified by this method callIllegalArgumentException
- if a value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(BooleanCollection values)
This implementation uses add(boolean)
.
addAll
in interface BooleanCollection
values
- the values to add to this collection, null treated as empty collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if a value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean removeFirst(boolean value)
This implementation uses iterator().remove()
.
removeFirst
in interface BooleanCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(boolean value)
This implementation uses iterator().remove()
.
removeAll
in interface BooleanCollection
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(boolean[] values)
This implementation uses iterator().remove()
.
removeAll
in interface BooleanCollection
values
- the values to remove from this collection, null treated as empty arraytrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(BooleanCollection values)
This implementation uses iterator().remove()
.
removeAll
in interface BooleanCollection
values
- the values to remove from this collection, null treated as empty collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(boolean[] values)
This implementation uses iterator().remove()
.
retainAll
in interface BooleanCollection
values
- the values to remove from this collection, null treated as empty arraytrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(BooleanCollection values)
This implementation uses iterator().remove()
.
retainAll
in interface BooleanCollection
values
- the values to retain in this collection, null treated as empty collectiontrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean contains(Object value)
Boolean
value.
This implementation uses contains(boolean)
.
contains
in interface Collection<Boolean>
value
- the value to search fortrue
if the value is foundpublic boolean containsAll(Collection<?> coll)
This implementation uses containsAll(boolean[])
.
containsAll
in interface Collection<Boolean>
coll
- the collection of values to search fortrue
if all the values are foundpublic boolean containsAny(Collection<?> coll)
false
is returned.
This implementation uses containsAny(boolean[])
.
containsAny
in interface PrimitiveCollection<Boolean>
coll
- the collection of values to search fortrue
if at least one of the values is foundpublic Object[] toArray()
Boolean
.toArray
in interface Collection<Boolean>
Boolean
public <T> T[] toArray(T[] array)
toArray
in interface Collection<Boolean>
array
- the array to populateBoolean
public boolean add(Boolean value)
Boolean
value to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses add(boolean)
.
add
in interface Collection<Boolean>
value
- the value to add to this collectiontrue
if this collection was modified by this method callIllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean addAll(Collection<? extends Boolean> coll)
Boolean
values to this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses addAll(boolean[])
.
addAll
in interface Collection<Boolean>
coll
- the values to add to this collectiontrue
if this list was modified by this method callIndexOutOfBoundsException
- if the index is invalidClassCastException
- if any object is not Boolean
IllegalArgumentException
- if value is rejected by this collectionUnsupportedOperationException
- if not supported by this collectionpublic boolean remove(Object value)
Boolean
value from
this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be removed from.
This implementation uses removeFirst(boolean)
.
remove
in interface Collection<Boolean>
value
- the value to removetrue
if this collection was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean removeAll(Collection<?> coll)
Boolean
values from this collection (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses removeAll(boolean[])
.
removeAll
in interface Collection<Boolean>
coll
- the values to remove from this collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic boolean retainAll(Collection<?> coll)
Boolean
values, removing other
values (optional operation).
This method is optional, throwing an UnsupportedOperationException if the collection cannot be added to.
This implementation uses retainAll(boolean[])
.
retainAll
in interface Collection<Boolean>
coll
- the values to retain in this collectiontrue
if this list was modified by this method callUnsupportedOperationException
- if not supported by this collectionpublic String toString()
The format used is as per Collection
.
protected void arrayCopy(int fromIndex, boolean[] dest, int destIndex, int size)
fromIndex
- the index to start fromdest
- the destination arraydestIndex
- the destination start indexsize
- the number of items to copyprotected boolean isAddModifiable()
This implementation returns false.
protected boolean isRemoveModifiable()
This implementation returns false.
public boolean isModifiable()
isModifiable
in interface PrimitiveCollectable<Boolean>
isModifiable
in class AbstractPrimitiveCollectable<Boolean>
protected void checkAddModifiable()
protected void checkRemoveModifiable()
protected Boolean toObject(boolean value)
boolean
with an Object wrapper.value
- the primitive valueprotected boolean isToPrimitivePossible(Object value)
This implementation only allows non-null Boolean objects.
value
- the Object wrapperprotected boolean toPrimitive(Object value)
Boolean
to retrieve the primitive boolean
.
This implementation only allows non-null Boolean objects.
value
- the Object to convert to a primitiveNullPointerException
- if the value is null and this is unacceptableClassCastException
- if the object is of an unsuitable typeprotected boolean[] toPrimitiveArray(Collection<?> coll)
Collection
to retrieve the primitive boolean
.
This implementation only allows non-null Boolean objects.
coll
- the Collection to convert to primitivesNullPointerException
- if the value is null and this is unacceptableClassCastException
- if any object is of an unsuitable typeCopyright © 2005-2012 Joda.org. All Rights Reserved.