@ MustBeLocked ( ELockType . WRITE ) private void _addItem ( @ Nonnull final IMPLTYPE aItem , @ Nonnull final EDAOActionType eActionType ) { ValueEnforcer . notNull ( aItem , "Item" ) ; ValueEnforcer . isTrue ( eActionType == EDAOActionType . CREATE || eActionType == EDAOActionType . UPDATE , "Invalid action type provided!" ) ; final String sID = aItem . getID ( ) ; final IMPLTYPE aOldItem = m_aMap . get ( sID ) ; if ( eActionType == EDAOActionType . CREATE ) { if ( aOldItem != null ) throw new IllegalArgumentException ( ClassHelper . getClassLocalName ( getDataTypeClass ( ) ) + " with ID '" + sID + "' is already in use and can therefore not be created again. Old item = " + aOldItem + "; New item = " + aItem ) ; } else { // Update if ( aOldItem == null ) throw new IllegalArgumentException ( ClassHelper . getClassLocalName ( getDataTypeClass ( ) ) + " with ID '" + sID + "' is not yet in use and can therefore not be updated! Updated item = " + aItem ) ; } m_aMap . put ( sID , aItem ) ; }
Add or update an item . Must only be invoked inside a write - lock .