private static <T> List<Metadata<T>> checkForDuplicates(List<Metadata<T>> list, LogMessageCallback messageCallback) {
Map<T, Metadata<T>> map = new HashMap<T, Metadata<T>>();
for (Metadata<T> item : list) {
Metadata<T> previousOccurrence = map.put(item.getValue(), item);
if (previousOccurrence != null) {
throw new DeploymentException(messageCallback.invoke(item.getValue(), item, previousOccurrence));
}
}
return list;
}