|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--gumbo.util.AbstractGroup
An abstract implementation of the Group interface. Intended as a lightweight proxy for a group's store, with lazy build of the store and this object's immutable views. Uses the decorator pattern to wrap an external target store or, if none, uses lazy build for an internal one.
Although collections have become efficient as regards memory and new object usage, this class goes farther by acting as a proxy for the target collection itself, with the lazy build target remaining null as long as it is empty or not being viewed. As such, all accessors test for isEmpty() before creating the backing store.
Constructor Summary | |
AbstractGroup()
Constructs an instance, with an empty lazy build store (see newGroupStore()). |
|
AbstractGroup(java.util.Collection init)
Constructs an instance, with an initialized store (see newGroupStore()). |
|
AbstractGroup(java.util.Collection init,
java.util.Collection target)
Constructs an instance, with a wrapped and initialized store. |
|
AbstractGroup(java.lang.Object[] init)
Constructs an instance, with an initialized store (see newGroupStore()). |
Method Summary | |
void |
add(int index,
java.lang.Object member)
Similar to List.add(int, Object), but functionally equivalent to Collection.add(Object) if index is <0. |
boolean |
add(java.lang.Object member)
|
boolean |
addAll(java.util.Collection members)
|
void |
addAll(int index,
java.util.Collection members)
Similar to List.addAll(int, Collection), but functionally equivalent to Collection.addAll(Collection) if index is <0. |
boolean |
contains(java.lang.Object member)
|
boolean |
containsAll(java.util.Collection members)
|
boolean |
containsAny(java.util.Collection members)
Returns true if this group contains any of the specified members. |
boolean |
equals(java.lang.Object obj)
|
Group |
getGroup()
Gets an immutable view of this group. |
protected java.util.Collection |
getGroupStore()
Called by the system to access the mutable backing store. |
java.util.List |
getList()
Gets a singleton immutable view of the group store as a list, which is useful for testing equality with another list. |
java.util.Set |
getSet()
Gets a singleton immutable view of the group store as a set, which is useful for testing equality with another set. |
int |
hashCode()
|
java.util.Iterator |
iterator()
|
protected java.util.Collection |
newGroupStore()
Called by the system when it needs to lazily build the group backing store. |
boolean |
remove(java.lang.Object member)
|
boolean |
removeAll(java.util.Collection members)
|
boolean |
retainAll(java.util.Collection members)
|
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.util.AbstractCollection |
clear, isEmpty, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
clear, isEmpty, toArray, toArray |
Constructor Detail |
public AbstractGroup()
public AbstractGroup(java.util.Collection init)
init
- The initial members (Object). None if null.public AbstractGroup(java.lang.Object[] init)
init
- The initial members. Never null.public AbstractGroup(java.util.Collection init, java.util.Collection target)
init
- The initial members (Object). None if null.target
- The target group store being wrapped. If null,
defaults to the lazy build target (see newGroupStore()). If
init is non-null, any contents will be lost.Method Detail |
protected java.util.Collection newGroupStore()
protected java.util.Collection getGroupStore()
java.lang.IllegalStateException
- New group store is null.public void add(int index, java.lang.Object member)
Group
add
in interface Group
index
- Index of the added member. If <0 the member is added
to the end of the list.member
- The member to be added, which may be null.public void addAll(int index, java.util.Collection members)
Group
addAll
in interface Group
index
- Index of the first added member. If <0 the members
are added to the end of the list.members
- The members (Object) to be added, which may be null.
Never null.public boolean containsAny(java.util.Collection members)
Group
containsAny
in interface Group
members
- The members, which may be null. Never null.
public Group getGroup()
Group
getGroup
in interface Group
public java.util.Set getSet()
Group
getSet
in interface Group
public java.util.List getList()
Group
getList
in interface Group
public boolean add(java.lang.Object member)
add
in interface java.util.Collection
add
in class java.util.AbstractCollection
public boolean addAll(java.util.Collection members)
addAll
in interface java.util.Collection
addAll
in class java.util.AbstractCollection
public boolean remove(java.lang.Object member)
remove
in interface java.util.Collection
remove
in class java.util.AbstractCollection
public boolean removeAll(java.util.Collection members)
removeAll
in interface java.util.Collection
removeAll
in class java.util.AbstractCollection
public boolean retainAll(java.util.Collection members)
retainAll
in interface java.util.Collection
retainAll
in class java.util.AbstractCollection
public boolean contains(java.lang.Object member)
contains
in interface java.util.Collection
contains
in class java.util.AbstractCollection
public boolean containsAll(java.util.Collection members)
containsAll
in interface java.util.Collection
containsAll
in class java.util.AbstractCollection
public java.util.Iterator iterator()
iterator
in interface java.util.Collection
iterator
in class java.util.AbstractCollection
public int size()
size
in interface java.util.Collection
size
in class java.util.AbstractCollection
public java.lang.String toString()
toString
in class java.util.AbstractCollection
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Collection
hashCode
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |