public class MapBeanProvider extends SimpleBeanProvider
A specialized BeanProvider
implementation for creating beans of
type java.util.Map
.
With this bean provider implementation either a
java.util.HashMap
or a java.util.LinkedHashMap
can
be created and populated. The mechanisms used here are very similar to the
ones used by CollectionBeanProvider
: an instance is
initialized with two lists of Dependency
objects - one
list represents the key, the other list represents the values of the map. The
getDependencies()
method returns a union of all these
dependencies. When the Map
bean is to be created, a new instance
of the correct Map
class is created. Then the dependencies for
the keys and values are resolved, and the corresponding objects are added to
the map.
Bean providers of this type are intended to be used together with a
LifeCycleBeanProvider
that controls the creation of new
instances.
Implementation note: Objects of this class are immutable and thus can be shared between multiple threads.
Constructor and Description |
---|
MapBeanProvider(Collection<Dependency> keyDeps,
Collection<Dependency> valDeps,
boolean ordered)
Creates a new instance of
MapBeanProvider and initializes
it. |
Modifier and Type | Method and Description |
---|---|
protected Map<Object,Object> |
createMap()
Creates the map managed by this provider.
|
Object |
getBean(DependencyProvider dependencyProvider)
Returns the bean managed by this provider.
|
Class<?> |
getBeanClass(DependencyProvider dependencyProvider)
Returns the class of the managed bean.
|
Set<Dependency> |
getDependencies()
Returns the dependencies of this bean provider.
|
Collection<Dependency> |
getKeyDependencies()
Returns the dependencies for the keys of the map.
|
Collection<Dependency> |
getValueDependencies()
Returns the dependencies for the values of the map.
|
boolean |
isOrdered()
Returns the ordered flag.
|
getLockID, isBeanAvailable, setLockID, shutdown
public MapBeanProvider(Collection<Dependency> keyDeps, Collection<Dependency> valDeps, boolean ordered)
MapBeanProvider
and initializes
it.keyDeps
- the dependencies for the keys of the map (must not be
null)valDeps
- the dependencies for the values of the map (must not be
null)ordered
- a flag whether the order of the dependencies should be
maintainedIllegalArgumentException
- if either keyDeps
or
valDeps
is null or the sizes of the
collections are differentpublic Collection<Dependency> getKeyDependencies()
public Collection<Dependency> getValueDependencies()
public boolean isOrdered()
public Object getBean(DependencyProvider dependencyProvider)
createMap()
to create the map. Then the dependencies for
keys and values are resolved and added to the map.dependencyProvider
- the dependency providerpublic Class<?> getBeanClass(DependencyProvider dependencyProvider)
java.util.Map
class.dependencyProvider
- the dependency providerpublic Set<Dependency> getDependencies()
getDependencies
in interface BeanProvider
getDependencies
in class SimpleBeanProvider
Dependency
Copyright © 2016 The JGUIraffe Team. All rights reserved.