app/controllers/DestinationsController.java
private void newPublicDestination(Destination newPublicDestination) {
        Optional<List<Destination>> destinationList = destinationRepository.checkForSameDestination(newPublicDestination);
        if (destinationList.isPresent()) {
            for (Destination destination : destinationList.get()) {
                if (destination.getDestinationId() != newPublicDestination.getDestinationId()) {
                    destinationRepository.followDestination(newPublicDestination.getDestinationId(), destination.getProfileId());
                    Optional<List<TripDestination>> tripDestinationList = tripDestinationsRepository.getTripDestsWithDestId(destination.getDestinationId());
                    if (tripDestinationList.isPresent()) {
                        for (TripDestination tripDestination : tripDestinationList.get()) {
                            tripDestinationsRepository.editTripId(tripDestination, newPublicDestination.getDestinationId());
                        }
                    }
                    destinationRepository.delete(destination.getDestinationId());
                }
            }
        }
    }
/**
     * This function will inspect all private destinations for all users and swap any private destinations for the
     * new public destination if they are the same.
     *
     * @param newPublicDestination, the new private destination
     */
This function will inspect all private destinations for all users and swap any private destinations for the
new public destination if they are the same.

@param newPublicDestination, the new private destination
This function will inspect all private destinations for all users and swap any private destinations for the new public destination if they are the same . @param newPublicDestination the new private destination
private void newPublicDestination(Destination newPublicDestination) {
        Optional<List<Destination>> destinationList = destinationRepository.checkForSameDestination(newPublicDestination);
        if (destinationList.isPresent()) {
            for (Destination destination : destinationList.get()) {
                if (destination.getDestinationId() != newPublicDestination.getDestinationId()) {
                    destinationRepository.followDestination(newPublicDestination.getDestinationId(), destination.getProfileId());
                    Optional<List<TripDestination>> tripDestinationList = tripDestinationsRepository.getTripDestsWithDestId(destination.getDestinationId());
                    if (tripDestinationList.isPresent()) {
                        for (TripDestination tripDestination : tripDestinationList.get()) {
                            tripDestinationsRepository.editTripId(tripDestination, newPublicDestination.getDestinationId());
                        }
                    }
                    destinationRepository.delete(destination.getDestinationId());
                }
            }
        }
    }
private void newPublicDestination ( Destination newPublicDestination ) { Optional < List < Destination > > destinationList = destinationRepository . checkForSameDestination ( newPublicDestination ) ; if ( destinationList . isPresent ( ) ) { for ( Destination destination : destinationList . get ( ) ) { if ( destination . getDestinationId ( ) != newPublicDestination . getDestinationId ( ) ) { destinationRepository . followDestination ( newPublicDestination . getDestinationId ( ) , destination . getProfileId ( ) ) ; Optional < List < TripDestination > > tripDestinationList = tripDestinationsRepository . getTripDestsWithDestId ( destination . getDestinationId ( ) ) ; if ( tripDestinationList . isPresent ( ) ) { for ( TripDestination tripDestination : tripDestinationList . get ( ) ) { tripDestinationsRepository . editTripId ( tripDestination , newPublicDestination . getDestinationId ( ) ) ; } } destinationRepository . delete ( destination . getDestinationId ( ) ) ; } } } }
This function will inspect all private destinations for all users and swap any private destinations for the
 new public destination if they are the same.
This function will inspect all private destinations for all users and swap any private destinations for the new public destination if they are the same .