package seedu.whatnow.storage;

//@@author A0126240W-reused
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import seedu.whatnow.commons.exceptions.IllegalValueException;
import seedu.whatnow.commons.util.CollectionUtil;
import seedu.whatnow.model.ReadOnlyWhatNow;
import seedu.whatnow.model.tag.Tag;
import seedu.whatnow.model.tag.UniqueTagList;
import seedu.whatnow.model.tag.UniqueTagList.DuplicateTagException;
import seedu.whatnow.model.task.ReadOnlyTask;
import seedu.whatnow.model.task.UniqueTaskList;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * An Immutable WhatNow that is serializable to XML format
 */
@XmlRootElement(name = "whatnow")
public class XmlSerializableWhatNow implements ReadOnlyWhatNow {

    @XmlElement
    private List<XmlAdaptedTask> tasks = new ArrayList<>();
    @XmlElement
    private List<Tag> tags = new ArrayList<>();

    /**
     * Empty constructor required for marshalling
     */
    public XmlSerializableWhatNow() {
    }

    /**
     * Conversion
     */
    public XmlSerializableWhatNow(ReadOnlyWhatNow src) {
        tasks.addAll(src.getTaskList().stream().map(XmlAdaptedTask::new).collect(Collectors.toList()));
        tags = src.getTagList();
    }

    @SuppressWarnings("unchecked")
    @Override
    public UniqueTagList getUniqueTagList() {
        try {
            return new UniqueTagList(tags);
        } catch (DuplicateTagException e) {
            return new UniqueTagList((Set<Tag>)CollectionUtil.getUniqueElements(tags));
        }
    }

    @Override
    public UniqueTaskList getUniqueTaskList() {
        UniqueTaskList lists = new UniqueTaskList();
        for (XmlAdaptedTask p : tasks) {
            try {
                lists.add(p.toModelType());
            } catch (IllegalValueException e) {
                // TODO: better error handling
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return lists;
    }

    @Override
    public List<ReadOnlyTask> getTaskList() {
        return tasks.stream().map(p -> {
            try {
                return p.toModelType();
            } catch (IllegalValueException e) {
                e.printStackTrace();
                // TODO: better error handling
                return null;
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return null;
            }
        }).collect(Collectors.toCollection(ArrayList::new));
    }

    @Override
    public List<Tag> getTagList() {
        return Collections.unmodifiableList(tags);
    }

}

@@ -138,32 +138,79 @@
 .XmlRootElement;
+%0A%0Aimport seedu.whatnow.commons.core.LogsCenter;
 %0Aimport seedu.wh
@@ -307,16 +307,67 @@
 onUtil;%0A
+import seedu.whatnow.logic.commands.ChangeCommand;%0A
 import s
@@ -782,16 +782,49 @@
 il.Set;%0A
+import java.util.logging.Logger;%0A
 import j
@@ -1019,16 +1019,114 @@
 tNow %7B%0A%0A
+    private static final Logger logger = LogsCenter.getLogger(XmlSerializableWhatNow.class);%0A    %0A
     @Xml
@@ -1753,24 +1753,24 @@
 List(tags);%0A
-
         %7D ca
@@ -1793,32 +1793,112 @@
 gException e) %7B%0A
+            logger.info(%22Duplicated tags will be removed from the data file.%22);%0A
             retu

Add a log to log the removal of duplicate tags in the data file.