final Set<String> explicit = new HashSet<String>();
for (Map.Entry<String, Association> assocPair : current.entrySet()) {
final String assocName = assocPair.getKey();
final Association assoc = assocPair.getValue();
if (assoc == null || assoc.getEntries() == null) {
continue;
}
for (Object entryObject : assoc.getEntries()) {
final AssociationEntry entry = (AssociationEntry) entryObject;
if (entry.isExplicitMac()) {
final AssociationEntry inUseEntry = inUse.get(entry.getMac());
if (inUseEntry != null) {
final String inUseIp = inUseEntry.getIpAddress();
if (inUseIp == null || !inUseIp.equals(entry.getIpAddress())) {
logger.error("An explicit MAC in network '"+assocName+
"' collides with an in-use network entry! "+
"Explicit: "+ entry.toString() + "\nIn use: "+
inUseEntry.toString());
entry.setMac(null);
entry.setExplicitMac(false);
}
}
}
if (entry.isExplicitMac()) {
if (!explicit.add(entry.getMac())) {
logger.warn("Duplicate explicit MAC? "+ entry.getMac());
}
}
}
}
final List<String> macList =
new ArrayList<String>();
macList.addAll(inUse.keySet());
macList.addAll(explicit);
for (Association assoc : current.values()) {
for (Object entryObject : assoc.getEntries()) {
final AssociationEntry entry = (AssociationEntry) entryObject;
_setMac(entry, macPrefix, macList, explicit);
}
}