Package org.anchoranalysis.bean
Class BeanInstanceMap
Object
BeanInstanceMap
Maps a
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.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Populates from a list ofNamedBean
.void
addFrom
(BeanInstanceMap other) Populates the entries from another BeanInstanceMapboolean
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.
-
Constructor Details
-
BeanInstanceMap
public BeanInstanceMap()
-
-
Method Details
-
containsFamily
Is a particular family-type contained in the map?- Parameters:
familyType
- the class that defines the family- Returns:
- true if the family type already exists in the map.
-
getInstanceFor
Gets an instance from the map for a particular family-type.- Type Parameters:
T
- the family-type.- Parameters:
familyType
- the class that defines the family.- Returns:
- an instance from the map if exists.
-
putInstanceFor
Assigns an instance to a particular family-type.- Type Parameters:
T
- the family-type- Parameters:
familyType
- the class that defines the family.instance
- an instance to add.- Returns:
instance
.
-
removeInstanceFor
Removes any instance in the map of a particular family-type.If no instance exists, the method does notnhing.
- Type Parameters:
T
- the family-type- Parameters:
familyType
- the class that defines the family.
-
addFrom
Populates the entries from another BeanInstanceMapIt 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.
- Parameters:
other
- provides entries that are added to the current map
-
addFrom
public void addFrom(List<? extends NameValue<?>> listNamedInstances) throws BeanMisconfiguredException Populates from a list ofNamedBean
.Any existing map-entries are retained.
- Parameters:
listNamedInstances
- list ofNamedBean
. The name of each bean maps to the class in the map.- Throws:
BeanMisconfiguredException
- if the list ofNamedBean
contains an invalid class.
-