org.decisiondeck.utils.collections
Class AbstractSetView<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<T>
          extended by org.decisiondeck.utils.collections.AbstractSetView<T>
Type Parameters:
T - the type of the objects in the set view and the underlying set.
All Implemented Interfaces:
Iterable<T>, Collection<T>, Set<T>

public abstract class AbstractSetView<T>
extends AbstractSet<T>
implements Set<T>

A set view that wraps an other set. When the user calls {#remove(Object)} on this view, if the underlying set contains the object, this view calls first beforeRemove(Object), then justRemove(Object), then afterRemove(Object). Extenders of this view may override the methods to do appropriate job before or after removal. When an iterator is asked on this view, and the iterator remove method is used, this view first calls beforeRemove(Object), then removes the object using the iterator method, then calls afterRemove(Object).


Constructor Summary
AbstractSetView(Set<T> delegateSet)
           
 
Method Summary
 boolean add(T e)
           
 boolean contains(Object c)
           
 Iterator<T> iterator()
           
 boolean remove(Object o)
           
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

AbstractSetView

public AbstractSetView(Set<T> delegateSet)
Parameters:
delegateSet - not null.
Method Detail

add

public boolean add(T e)
Specified by:
add in interface Collection<T>
Specified by:
add in interface Set<T>
Overrides:
add in class AbstractCollection<T>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<T>
Specified by:
remove in interface Set<T>
Overrides:
remove in class AbstractCollection<T>

contains

public boolean contains(Object c)
Specified by:
contains in interface Collection<T>
Specified by:
contains in interface Set<T>
Overrides:
contains in class AbstractCollection<T>

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface Set<T>
Specified by:
iterator in class AbstractCollection<T>

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in interface Set<T>
Specified by:
size in class AbstractCollection<T>


Copyright © 2011. All Rights Reserved.