public class BeanInstanceMap extends Object
AnchorBean
family-type to a bean that belongs to the family.
A family-type is always expresses as a class object for the most-abstract (i.e. highest level parent) of all classes in the family.
Constructor and Description |
---|
BeanInstanceMap() |
Modifier and Type | Method and Description |
---|---|
void |
addFrom(BeanInstanceMap other)
Populates the entries from another BeanInstanceMap
|
void |
addFrom(List<NamedBean<?>> listNamedInstances)
Populates from a list of
NamedBean . |
boolean |
containsFamily(Class<?> familyType)
Is a particular family-type contained in the map?
|
<T> Optional<T> |
getInstanceFor(Class<? extends T> familyType)
Gets an instance from the map for a particular family-type.
|
<T> T |
putInstanceFor(Class<? extends T> familyType,
T instance)
Assigns an instance to a particular family-type.
|
<T> void |
removeInstanceFor(Class<? extends T> familyType)
Removes any instance in the map of a particular family-type.
|
public boolean containsFamily(Class<?> familyType)
familyType
- the class that defines the familypublic <T> Optional<T> getInstanceFor(Class<? extends T> familyType)
T
- the family-type.familyType
- the class that defines the family.public <T> T putInstanceFor(Class<? extends T> familyType, T instance)
T
- the family-typefamilyType
- the class that defines the family.instance
- an instance to add.instance
.public <T> void removeInstanceFor(Class<? extends T> familyType)
If no instance exists, the method does notnhing.
T
- the family-typefamilyType
- the class that defines the family.public void addFrom(BeanInstanceMap other)
It is a "shallow-copy". No duplication of values occurs. So after the function is completed, any object references from other will also exist in this map.
Any existing map-entries are retained.
other
- provides entries that are added to the current mappublic void addFrom(List<NamedBean<?>> listNamedInstances) throws BeanMisconfiguredException
NamedBean
.
Any existing map-entries are retained.
listNamedInstances
- list of NamedBean
. The name of each bean maps to the class
in the map.BeanMisconfiguredException
- if the list of NamedBean
contains an invalid
class.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.