use of org.datanucleus.util.MultiMap in project datanucleus-core by datanucleus.
the class FetchGroupManager method addFetchGroup.
/**
* Method to add a dynamic fetch group.
* @param grp The fetch group
*/
public synchronized void addFetchGroup(FetchGroup grp) {
if (fetchGroupByName == null) {
fetchGroupByName = new MultiMap();
}
// Check for existing group with this name for this type
Collection<FetchGroup> coll = (Collection<FetchGroup>) fetchGroupByName.get(grp.getName());
if (coll != null) {
// Check for existing entry for this name and class
Iterator<FetchGroup> iter = coll.iterator();
while (iter.hasNext()) {
FetchGroup existingGrp = iter.next();
if (existingGrp.getName().equals(grp.getName()) && existingGrp.getType().getName().equals(grp.getType().getName())) {
// Already have a group for this name+class so replace it
// Remove the old group from use
existingGrp.disconnectFromListeners();
// Remove the old group
iter.remove();
}
}
}
fetchGroupByName.put(grp.getName(), grp);
}
Aggregations