package seedu.address.model.person;

import seedu.address.commons.util.CollectionUtil;
import seedu.address.model.tag.UniqueTagList;

import java.util.Objects;

/**
 * Represents a Person in the address book.
 * Guarantees: details are present and not null, field values are validated.
 */
public class Person implements ReadOnlyPerson {

    private Name name;
    private Phone phone;
    private Email email;
    private Address address;

    private UniqueTagList tags;

    /**
     * Every field must be present and not null.
     */
    public Person(Name name, Phone phone, Email email, Address address, UniqueTagList tags) {
        assert !CollectionUtil.isAnyNull(name, phone, email, address, tags);
        this.name = name;
        this.phone = phone;
        this.email = email;
        this.address = address;
        this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list
    }

    /**
     * Creates a copy of the given ReadOnlyPerson.
     */
    public Person(ReadOnlyPerson source) {
        this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags());
    }

    @Override
    public Name getName() {
        return name;
    }

    @Override
    public Phone getPhone() {
        return phone;
    }

    @Override
    public Email getEmail() {
        return email;
    }

    @Override
    public Address getAddress() {
        return address;
    }

    @Override
    public UniqueTagList getTags() {
        return new UniqueTagList(tags);
    }

    /**
     * Replaces this person's tags with the tags in the argument tag list.
     */
    public void setTags(UniqueTagList replacement) {
        tags.setTags(replacement);
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof ReadOnlyPerson // instanceof handles nulls
                && this.isSameStateAs((ReadOnlyPerson) other));
    }

    @Override
    public int hashCode() {
        // use this method for custom fields hashing instead of implementing your own
        return Objects.hash(name, phone, email, address, tags);
    }

    @Override
    public String toString() {
        return getAsText();
    }

}

@@ -1158,573 +1158,1418 @@
     
-@Override%0A    public Name getName() %7B%0A        return name;%0A    %7D%0A%0A    @Override%0A    public Phone getPhone() %7B%0A        return phone;%0A    %7D%0A%0A    @Override%0A    public Email getEmail() %7B%0A        return email;%0A    %7D%0A%0A    @Override%0A    public Address getAddress() %7B%0A        return address;%0A    %7D%0A%0A    @Override%0A    public UniqueTagList getTags() %7B%0A        return new UniqueTagList(tags);%0A    %7D%0A%0A    /**%0A     * Replaces this person's tags with the tags in the argument tag list.%0A     */%0A    public void setTags(UniqueTagList replacement) %7B%0A        tags.setTags(replacement
+public void setName(Name name) %7B%0A        assert name != null;%0A        this.name = name;%0A    %7D%0A%0A    @Override%0A    public Name getName() %7B%0A        return name;%0A    %7D%0A%0A    public void setPhone(Phone phone) %7B%0A        assert phone != null;%0A        this.phone = phone;%0A    %7D%0A%0A    @Override%0A    public Phone getPhone() %7B%0A        return phone;%0A    %7D%0A%0A    public void setEmail(Email email) %7B%0A        assert email != null;%0A        this.email = email;%0A    %7D%0A%0A    @Override%0A    public Email getEmail() %7B%0A        return email;%0A    %7D%0A%0A    public void setAddress(Address address) %7B%0A        assert address != null;%0A        this.address = address;%0A    %7D%0A%0A    @Override%0A    public Address getAddress() %7B%0A        return address;%0A    %7D%0A%0A    @Override%0A    public UniqueTagList getTags() %7B%0A        return new UniqueTagList(tags);%0A    %7D%0A%0A    /**%0A     * Replaces this person's tags with the tags in the argument tag list.%0A     */%0A    public void setTags(UniqueTagList replacement) %7B%0A        tags.setTags(replacement);%0A    %7D%0A%0A    /**%0A     * Updates this person with the details of %7B@code replacement%7D.%0A     */%0A    public void resetData(ReadOnlyPerson replacement) %7B%0A        assert replacement != null;%0A%0A        this.setName(replacement.getName());%0A        this.setPhone(replacement.getPhone());%0A        this.setEmail(replacement.getEmail());%0A        this.setAddress(replacement.getAddress());%0A        this.setTags(replacement.getTags()
 );%0A 

make Person mutable