Skip to content
Snippets Groups Projects
Commit e1f338c9 authored by brinn's avatar brinn
Browse files

change: optimize method add()

SVN: 4030
parent b480cc95
No related branches found
No related tags found
No related merge requests found
......@@ -106,21 +106,12 @@ public class TableMap<K, E> implements Iterable<E>
public final void add(final E row)
{
final K key = extractor.getKey(row);
if (map.get(key) != null)
{
switch (uniqueKeyViolationStrategy)
{
case KEEP_FIRST:
break;
case KEEP_LAST:
map.put(key, row);
break;
case ERROR:
throw new UniqueKeyViolationException("Key '" + key.toString() + "' already in the map.");
}
} else
if (uniqueKeyViolationStrategy == UniqueKeyViolationStrategy.KEEP_LAST || map.get(key) == null)
{
map.put(key, row);
} else if (uniqueKeyViolationStrategy == UniqueKeyViolationStrategy.ERROR)
{
throw new UniqueKeyViolationException("Key '" + key.toString() + "' already in the map.");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment