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
CollectionBeanProviderimplementation that creates ajava.util.Setbean.The
createCollection()method is implemented to create a concrete implementation of thejava.util.Setinterface. Depending on theorderedflag that can be passed to the constructor either ajava.util.HashSet(iforderedis false) or ajava.util.LinkedHashSet(iforderedis 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 ofSetBeanProviderand 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.booleanisOrdered()Returns theorderedflag.-
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 ofSetBeanProviderand 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 theorderedflag. This flag determines the type of the collection created by this bean provider.- Returns:
- the
orderedflag
-
createCollection
protected Collection<Object> createCollection(int size)
Creates the collection managed by this bean provider. This implementation will return an implementation of thejava.util.Setinterface (the concrete type depends on theorderedproperty.- Specified by:
createCollectionin classCollectionBeanProvider- Parameters:
size- the size of the collection- Returns:
- a new instance of the collection managed by this bean provider
-
-