package WriterImplementation;

import Models.DatabaseConfig;
import WriterInterface.DBManagerInterface;
import java.util.HashMap;

public class DBManagerImpl implements DBManagerInterface{
    
    private static DBManagerImpl _dbManagerImpl;
    private final HashMap<String, DatabaseConfig> dbConfigs;
    
    private DBManagerImpl() {
        this.dbConfigs = new HashMap<>();
        if( _dbManagerImpl != null ) {
            throw new InstantiationError( "More instances of this object cannot be created." );
        }
    }
    
    private synchronized  static void createInstance(){
        if(_dbManagerImpl==null){
            _dbManagerImpl  = new DBManagerImpl();
        }
    }        
    
    public static  DBManagerImpl getInstace(){
        if(_dbManagerImpl==null) createInstance();
        return _dbManagerImpl;
    }
        
    
    @Override
    public DatabaseConfig getDatabaseConfig(String alias) {
        return dbConfigs.get(alias);        
    }

    @Override
    public void addDatabaseConfig(DatabaseConfig dataBaseConfig) {
        dbConfigs.put(dataBaseConfig.getAlias(), dataBaseConfig);        
    }
    

}

@@ -24,16 +24,53 @@
 ation;%0A%0A
+import Exception.DBManagerException;%0A
 import M
@@ -73,17 +73,16 @@
 rt Model
-s
 .Databas
@@ -1090,18 +1090,239 @@
 Config) 
-%7B%0A
+throws DBManagerException%7B%0A        if(databaseAliasExists(dataBaseConfig.getAlias()))%7B%0A            throw new DBManagerException(%22A database with the alias %22+dataBaseConfig.getAlias()+%22 already exists.%22);%0A        %7Delse%7B%0A    
         
@@ -1383,24 +1383,28 @@
 g);        %0A
+    
     %7D%0A    %0A%0A
@@ -1401,12 +1401,124 @@
   %7D%0A    
+%7D%0A    %0A    private boolean databaseAliasExists(String alias)%7B%0A        return dbConfigs.containsKey(alias);%0A    %7D
 %0A%0A%7D%0A

Update of DBManagerImpl and new Exception