src/main/java/nl/bioinf/minorapplicationdesign/ontpillen/model/data_storage/InMemoryDrugDao.java
/**
     * Method that will add drug to the dao.
     * It checks if the drug already exists, if it exists the method throws an IllegalArgumentException.
     * It will check if the given drug is a DrugSubstance or a DrugGroup and will add it to the correct list accordingly
     * @param drug Drug object to be added
     */
Method that will add drug to the dao.
It checks if the drug already exists, if it exists the method throws an IllegalArgumentException.
It will check if the given drug is a DrugSubstance or a DrugGroup and will add it to the correct list accordingly
@param drug Drug object to be added
Method that will add drug to the dao . It checks if the drug already exists if it exists the method throws an IllegalArgumentException . It will check if the given drug is a DrugSubstance or a DrugGroup and will add it to the correct list accordingly @param drug Drug object to be added
@Override
    public void addDrug(Drug drug) {
        if(drugInDrugDao(drug.name)){
            throw new IllegalArgumentException("Cannot add drug that already exists");
        }
        allDrugs.put(drug.getName(), drug);
        if (drug instanceof DrugSubstance) {
            drugSubstances.add(drug.getName());
        }
        else if (drug instanceof DrugGroup && drug.getParent() == null) {
            mainDrugGroups.add(drug.getName());
        }
    }
@ Override public void addDrug ( Drug drug ) { if ( drugInDrugDao ( drug . name ) ) { throw new IllegalArgumentException ( "Cannot add drug that already exists" ) ; } allDrugs . put ( drug . getName ( ) , drug ) ; if ( drug instanceof DrugSubstance ) { drugSubstances . add ( drug . getName ( ) ) ; } else if ( drug instanceof DrugGroup && drug . getParent ( ) == null ) { mainDrugGroups . add ( drug . getName ( ) ) ; } }
Method that will add drug to the dao.
Method that will add drug to the dao .