private static final void addUnique ( final Map < String , Unit > map , final String key , final Unit newUnit ) throws UnitExistsException { final Unit oldUnit = map . put ( key , newUnit ) ; if ( oldUnit != null && ! oldUnit . equals ( newUnit ) ) { throw new UnitExistsException ( oldUnit , newUnit ) ; } }
Adds a unique unit to a map ..