* @param classIter Class meta iterator
* @return A lookup of ClassMeta arrays keyed by ClassMeta
*/
public static Lookup createValueInverseDependencyMap(Iterator classIter)
{
MultiMap valueInvDepMap = new MultiMap();
while (classIter.hasNext())
{
final ClassMeta clazz = (ClassMeta)classIter.next();
for (Iterator attrIter = clazz.getAttributeMetaIterator(); attrIter.hasNext();)
{
final AttributeMeta startAttr = (AttributeMeta)attrIter.next();
if (startAttr.isClientCalculable())
{
curDep: for (Pair depencies = startAttr.getValueDependencyAssociations(); depencies != null; depencies = depencies
.getNext())
{
ClassMeta cur = clazz;
for (Pair path = (Pair)depencies.getHead(); path != null; path = path.getNext())
{
String sAttributeName = (String)path.getHead();
AttributeMeta segmentAttr = cur.findAttributeMeta(sAttributeName);
if (segmentAttr == null || segmentAttr.isCollection())
{
continue curDep;
}
valueInvDepMap.add(segmentAttr, startAttr);
if (!(segmentAttr.getType() instanceof ClassMeta))
{
continue curDep;
}
cur = (ClassMeta)segmentAttr.getType();
}
}
}
}
}
Lookup out = new HashTab(valueInvDepMap.keyCount());
// Transfer to a map of arrays
for (Lookup.Iterator it = valueInvDepMap.iterator(); it.hasNext();)
{
AttributeMeta key = (AttributeMeta)it.next();
Collection col = (Collection)it.getValue();
out.put(key, col.toArray(new AttributeMeta[col.size()]));