src/main/java/seedu/planner/model/ModelManager.java
private void updateMapping(Accommodation oldAcc, Accommodation newAcc) {
        if (oldAcc.getContact().isPresent()) { //checks for existing mapping
            Contact oldContact = oldAcc.getContact().get();
            if (contactActivityMap.containsKey(oldContact) && contactAccommodationMap.containsKey(oldContact)) {
                //if linked to both
                contactAccommodationMap.remove(oldContact);
            } else if (contactAccommodationMap.containsKey(oldContact) && !contactActivityMap.containsKey(oldContact)) {
                removeContact(oldContact);
            }
            if (newAcc.getContact().isPresent()) {
                Contact newContact = newAcc.getContact().get();
                if (!hasContact(newContact)) {
                    addContact(newContact);
                }
                contactAccommodationMap.put(newContact, newAcc);
            }
        } else if (newAcc.getContact().isPresent()) { //activity gets new contact previously not there
            Contact newContact = newAcc.getContact().get();
            if (!hasContact(newContact)) {
                addContact(newContact);
            }
            addAccommodationMapping(newAcc);
        }
    }
/**
     * Updates the mapping when there is a change to an {@code Activity}. When the {@code Contact} of the
     * {@code Activity} is changed, the {@code Contact} is also updated.
     */
Updates the mapping when there is a change to an  Activity. When the  Contact of the
Activity is changed, the  Contact is also updated.
Updates the mapping when there is a change to an Activity . When the Contact of the Activity is changed the Contact is also updated .
private void updateMapping(Accommodation oldAcc, Accommodation newAcc) {
        if (oldAcc.getContact().isPresent()) { 
            Contact oldContact = oldAcc.getContact().get();
            if (contactActivityMap.containsKey(oldContact) && contactAccommodationMap.containsKey(oldContact)) {
                contactAccommodationMap.remove(oldContact);
            } else if (contactAccommodationMap.containsKey(oldContact) && !contactActivityMap.containsKey(oldContact)) {
                removeContact(oldContact);
            }
            if (newAcc.getContact().isPresent()) {
                Contact newContact = newAcc.getContact().get();
                if (!hasContact(newContact)) {
                    addContact(newContact);
                }
                contactAccommodationMap.put(newContact, newAcc);
            }
        } else if (newAcc.getContact().isPresent()) { 
            Contact newContact = newAcc.getContact().get();
            if (!hasContact(newContact)) {
                addContact(newContact);
            }
            addAccommodationMapping(newAcc);
        }
    }
private void updateMapping ( Accommodation oldAcc , Accommodation newAcc ) { if ( oldAcc . getContact ( ) . isPresent ( ) ) { Contact oldContact = oldAcc . getContact ( ) . get ( ) ; if ( contactActivityMap . containsKey ( oldContact ) && contactAccommodationMap . containsKey ( oldContact ) ) { contactAccommodationMap . remove ( oldContact ) ; } else if ( contactAccommodationMap . containsKey ( oldContact ) && ! contactActivityMap . containsKey ( oldContact ) ) { removeContact ( oldContact ) ; } if ( newAcc . getContact ( ) . isPresent ( ) ) { Contact newContact = newAcc . getContact ( ) . get ( ) ; if ( ! hasContact ( newContact ) ) { addContact ( newContact ) ; } contactAccommodationMap . put ( newContact , newAcc ) ; } } else if ( newAcc . getContact ( ) . isPresent ( ) ) { Contact newContact = newAcc . getContact ( ) . get ( ) ; if ( ! hasContact ( newContact ) ) { addContact ( newContact ) ; } addAccommodationMapping ( newAcc ) ; } }
Updates the mapping when there is a change to an {@code Activity}.
Updates the mapping when there is a change to an { @code Activity } .
//checks for existing mapping //if linked to both //activity gets new contact previously not there