org.richfaces.cdk.model
Class ModelSet<E extends ModelElement<? super E>>

java.lang.Object
  extended by org.richfaces.cdk.model.ModelSet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, ModelCollection<E>, Visitable

public class ModelSet<E extends ModelElement<? super E>>
extends java.lang.Object
implements ModelCollection<E>, java.util.Set<E>

Base class for all model collections. This collection use Mergeable.same(Object) method instead of equals to lookup objects in the contains(Object) and remove(Object) methods. In addition, it merges same objects instead of replace in the add(ModelElement) method.

Author:
asmirnov@exadel.com

Constructor Summary
ModelSet()
           
 
Method Summary
<R,D> R
accept(R result, Visitor<R,D> visitor, D data)
           
<R,D> R
accept(Visitor<R,D> visitor, D data)
           
 boolean add(E e)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
static
<T extends ModelElement<? super T>>
ModelSet<T>
create()
           
static
<T extends ModelElement<? super T>>
ModelSet<T>
create(java.util.Comparator<T> comparator)
           
 E find(com.google.common.base.Predicate<? super E> predicate)
           
 java.util.Comparator<E> getComparator()
          

 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 void setComparator(java.util.Comparator<E> comparator)
          

 int size()
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

ModelSet

public ModelSet()
Method Detail

create

public static <T extends ModelElement<? super T>> ModelSet<T> create()

create

public static <T extends ModelElement<? super T>> ModelSet<T> create(java.util.Comparator<T> comparator)

getComparator

public java.util.Comparator<E> getComparator()

Returns:
the comparator

setComparator

public void setComparator(java.util.Comparator<E> comparator)

Parameters:
comparator - the comparator to set

find

public E find(com.google.common.base.Predicate<? super E> predicate)
Specified by:
find in interface ModelCollection<E extends ModelElement<? super E>>

add

public boolean add(E e)
Specified by:
add in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
add in interface java.util.Set<E extends ModelElement<? super E>>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
addAll in interface java.util.Set<E extends ModelElement<? super E>>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
clear in interface java.util.Set<E extends ModelElement<? super E>>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
contains in interface java.util.Set<E extends ModelElement<? super E>>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
containsAll in interface java.util.Set<E extends ModelElement<? super E>>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
isEmpty in interface java.util.Set<E extends ModelElement<? super E>>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E extends ModelElement<? super E>>
Specified by:
iterator in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
iterator in interface java.util.Set<E extends ModelElement<? super E>>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
remove in interface java.util.Set<E extends ModelElement<? super E>>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
removeAll in interface java.util.Set<E extends ModelElement<? super E>>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
retainAll in interface java.util.Set<E extends ModelElement<? super E>>

size

public int size()
Specified by:
size in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
size in interface java.util.Set<E extends ModelElement<? super E>>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
toArray in interface java.util.Set<E extends ModelElement<? super E>>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E extends ModelElement<? super E>>
Specified by:
toArray in interface java.util.Set<E extends ModelElement<? super E>>

accept

public <R,D> R accept(R result,
                      Visitor<R,D> visitor,
                      D data)
Specified by:
accept in interface ModelCollection<E extends ModelElement<? super E>>

accept

public <R,D> R accept(Visitor<R,D> visitor,
                      D data)
Specified by:
accept in interface Visitable


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.