src/main/java/seedu/address/logic/commands/ImportCommand.java
@Override
    public CommandResult executeUndoableCommand() throws CommandException {
        requireNonNull(model);

        if (parcels.isEmpty()) {
            throw new CommandException(MESSAGE_INVALID_FILE_EMPTY);
        }

        List<ReadOnlyParcel> uniqueParcels = new ArrayList<>(); // list of unique parcels added to Ark.
        List<ReadOnlyParcel> duplicateParcels = new ArrayList<>(); // list of duplicate parcels that are not added
        List<ReadOnlyParcel> storedParcels = model.getAddressBook().getParcelList(); // parcels already stored in Ark

        // check if all parcels are duplicates
        if (storedParcels.containsAll(parcels)) {
            throw new CommandException(MESSAGE_INVALID_DUPLICATE_PARCELS);
        }

        model.addAllParcels(parcels, uniqueParcels, duplicateParcels);

        String addedParcelsString = getImportFormattedParcelListString(uniqueParcels);
        String duplicatedParcelsString = getImportFormattedParcelListString(duplicateParcels);

        return new CommandResult(String.format(MESSAGE_SUCCESS, uniqueParcels.size(), duplicateParcels.size(),
                addedParcelsString, duplicatedParcelsString));
    }
/**
     * Adds all unique parcels in {@code parcels} to the {@link UniqueParcelList} of the {@link AddressBook}. Ignores
     * parcels that will create duplicates in the {@link UniqueParcelList}. To see the internal logic, see
     * {@link ModelManager#addAllParcels(List, List, List)} for more information
     *
     * @return {@link CommandResult} created by {@link ImportCommand#executeUndoableCommand()}
     * @throws CommandException if {@code parcels} contain only duplicate parcels.
     * @see ModelManager#addAllParcels(List, List, List)
     */
Adds all unique parcels in  parcels to the  UniqueParcelList of the  AddressBook. Ignores
parcels that will create duplicates in the  UniqueParcelList. To see the internal logic, see
ModelManager#addAllParcels(List, List, List) for more information


Adds all unique parcels in parcels to the UniqueParcelList of the AddressBook . Ignores parcels that will create duplicates in the UniqueParcelList . To see the internal logic see ModelManager#addAllParcels ( List List List ) for more information
@Override
    public CommandResult executeUndoableCommand() throws CommandException {
        requireNonNull(model);
        if (parcels.isEmpty()) {
            throw new CommandException(MESSAGE_INVALID_FILE_EMPTY);
        }
        List<ReadOnlyParcel> uniqueParcels = new ArrayList<>(); 
        List<ReadOnlyParcel> duplicateParcels = new ArrayList<>(); 
        List<ReadOnlyParcel> storedParcels = model.getAddressBook().getParcelList(); 
        if (storedParcels.containsAll(parcels)) {
            throw new CommandException(MESSAGE_INVALID_DUPLICATE_PARCELS);
        }
        model.addAllParcels(parcels, uniqueParcels, duplicateParcels);
        String addedParcelsString = getImportFormattedParcelListString(uniqueParcels);
        String duplicatedParcelsString = getImportFormattedParcelListString(duplicateParcels);
        return new CommandResult(String.format(MESSAGE_SUCCESS, uniqueParcels.size(), duplicateParcels.size(),
                addedParcelsString, duplicatedParcelsString));
    }
@ Override public CommandResult executeUndoableCommand ( ) throws CommandException { requireNonNull ( model ) ; if ( parcels . isEmpty ( ) ) { throw new CommandException ( MESSAGE_INVALID_FILE_EMPTY ) ; } List < ReadOnlyParcel > uniqueParcels = new ArrayList < > ( ) ; List < ReadOnlyParcel > duplicateParcels = new ArrayList < > ( ) ; List < ReadOnlyParcel > storedParcels = model . getAddressBook ( ) . getParcelList ( ) ; if ( storedParcels . containsAll ( parcels ) ) { throw new CommandException ( MESSAGE_INVALID_DUPLICATE_PARCELS ) ; } model . addAllParcels ( parcels , uniqueParcels , duplicateParcels ) ; String addedParcelsString = getImportFormattedParcelListString ( uniqueParcels ) ; String duplicatedParcelsString = getImportFormattedParcelListString ( duplicateParcels ) ; return new CommandResult ( String . format ( MESSAGE_SUCCESS , uniqueParcels . size ( ) , duplicateParcels . size ( ) , addedParcelsString , duplicatedParcelsString ) ) ; }
Adds all unique parcels in {@code parcels} to the {@link UniqueParcelList} of the {@link AddressBook}.
Adds all unique parcels in { @code parcels } to the { @link UniqueParcelList } of the { @link AddressBook } .
// list of unique parcels added to Ark. // list of duplicate parcels that are not added // parcels already stored in Ark // check if all parcels are duplicates