Class SetBeanProvider
- java.lang.Object
-
- net.sf.jguiraffe.di.impl.providers.SimpleBeanProvider
-
- net.sf.jguiraffe.di.impl.providers.CollectionBeanProvider
-
- net.sf.jguiraffe.di.impl.providers.SetBeanProvider
-
- All Implemented Interfaces:
BeanProvider
public class SetBeanProvider extends CollectionBeanProvider
A specialized
CollectionBeanProvider
implementation that creates ajava.util.Set
bean.The
createCollection()
method is implemented to create a concrete implementation of thejava.util.Set
interface. Depending on theordered
flag that can be passed to the constructor either ajava.util.HashSet
(ifordered
is false) or ajava.util.LinkedHashSet
(ifordered
is true) is created. In the latter case the set will remember the order of its elements.Implementation note: Objects of this class are immutable and thus can be shared between multiple threads.
- Version:
- $Id: SetBeanProvider.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description SetBeanProvider(Collection<Dependency> deps, boolean ordered)
Creates a new instance ofSetBeanProvider
and initializes it with the dependencies of its elements and the ordered flag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<Object>
createCollection(int size)
Creates the collection managed by this bean provider.boolean
isOrdered()
Returns theordered
flag.-
Methods inherited from class net.sf.jguiraffe.di.impl.providers.CollectionBeanProvider
getBean, getBeanClass, getDependencies, getElementDependencies
-
Methods inherited from class net.sf.jguiraffe.di.impl.providers.SimpleBeanProvider
getLockID, isBeanAvailable, setLockID, shutdown
-
-
-
-
Constructor Detail
-
SetBeanProvider
public SetBeanProvider(Collection<Dependency> deps, boolean ordered)
Creates a new instance ofSetBeanProvider
and initializes it with the dependencies of its elements and the ordered flag.- Parameters:
deps
- the dependencies representing the elements of the setordered
- a flag whether the set created should keep the order of its elements- Throws:
IllegalArgumentException
- if the collection with the dependencies is null
-
-
Method Detail
-
isOrdered
public boolean isOrdered()
Returns theordered
flag. This flag determines the type of the collection created by this bean provider.- Returns:
- the
ordered
flag
-
createCollection
protected Collection<Object> createCollection(int size)
Creates the collection managed by this bean provider. This implementation will return an implementation of thejava.util.Set
interface (the concrete type depends on theordered
property.- Specified by:
createCollection
in classCollectionBeanProvider
- Parameters:
size
- the size of the collection- Returns:
- a new instance of the collection managed by this bean provider
-
-