package seedu.address.testutil;

import java.util.Set;

import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.ReadOnlyPerson;
import seedu.address.model.tag.Tag;
import seedu.address.model.util.SampleDataUtil;

/**
 * A utility class to help with building Person objects.
 */
public class PersonBuilder {

    public static final String DEFAULT_NAME = "Alice Pauline";
    public static final String DEFAULT_PHONE = "85355255";
    public static final String DEFAULT_EMAIL = "alice@gmail.com";
    public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111";
    public static final String DEFAULT_TAGS = "friends";

    private Person person;

    public PersonBuilder() {
        Name defaultName = new Name(DEFAULT_NAME);
        Phone defaultPhone = new Phone(DEFAULT_PHONE);
        Email defaultEmail = new Email(DEFAULT_EMAIL);
        Address defaultAddress = new Address(DEFAULT_ADDRESS);
        Set<Tag> defaultTags = SampleDataUtil.getTagSet(DEFAULT_TAGS);
        this.person = new Person(defaultName, defaultPhone, defaultEmail, defaultAddress, defaultTags);
    }

    /**
     * Initializes the PersonBuilder with the data of {@code personToCopy}.
     */
    public PersonBuilder(ReadOnlyPerson personToCopy) {
        this.person = new Person(personToCopy);
    }

    /**
     * Sets the {@code Name} of the {@code Person} that we are building.
     */
    public PersonBuilder withName(String name) {
        this.person.setName(new Name(name));
        return this;
    }

    /**
     * Parses the {@code tags} into a {@code Set<Tag>} and set it to the {@code Person} that we are building.
     */
    public PersonBuilder withTags(String ... tags) {
        this.person.setTags(SampleDataUtil.getTagSet(tags));
        return this;
    }

    /**
     * Sets the {@code Address} of the {@code Person} that we are building.
     */
    public PersonBuilder withAddress(String address) {
        this.person.setAddress(new Address(address));
        return this;
    }

    /**
     * Sets the {@code Phone} of the {@code Person} that we are building.
     */
    public PersonBuilder withPhone(String phone) {
        this.person.setPhone(new Phone(phone));
        return this;
    }

    /**
     * Sets the {@code Email} of the {@code Person} that we are building.
     */
    public PersonBuilder withEmail(String email) {
        this.person.setEmail(new Email(email));
        return this;
    }

    public Person build() {
        return this.person;
    }

}

@@ -26,16 +26,42 @@
 tutil;%0A%0A
+import java.util.HashSet;%0A
 import j
@@ -854,29 +854,131 @@
 private 
-Pers
+Name name;%0A    private Ph
 on
+e
  p
-erson
+hone;%0A    private Email email;%0A    private Address address;%0A    private Set%3CTag%3E tags
 ;%0A%0A    p
@@ -1013,21 +1013,9 @@
     
-Name defaultN
+n
 ame 
@@ -1052,22 +1052,9 @@
     
-Phone defaultP
+p
 hone
@@ -1094,22 +1094,9 @@
     
-Email defaultE
+e
 mail
@@ -1136,24 +1136,9 @@
     
-Address defaultA
+a
 ddre
@@ -1184,25 +1184,9 @@
     
-Set%3CTag%3E defaultT
+t
 ags 
@@ -1231,112 +1231,8 @@
 S);%0A
-        this.person = new Person(defaultName, defaultPhone, defaultEmail, defaultAddress, defaultTags);%0A
     
@@ -1394,32 +1394,194 @@
     
-this.person = new Person
+name = personToCopy.getName();%0A        phone = personToCopy.getPhone();%0A        email = personToCopy.getEmail();%0A        address = personToCopy.getAddress();%0A        tags = new HashSet%3C%3E
 (per
@@ -1589,16 +1589,26 @@
 onToCopy
+.getTags()
 );%0A    %7D
@@ -1764,23 +1764,15 @@
 his.
-person.setName(
+name = 
 new 
@@ -1781,17 +1781,16 @@
 me(name)
-)
 ;%0A      
@@ -2007,23 +2007,15 @@
 his.
-person.setTags(
+tags = 
 Samp
@@ -2040,17 +2040,16 @@
 et(tags)
-)
 ;%0A      
@@ -2234,26 +2234,18 @@
 his.
-person.setA
+a
 ddress
-(
+ = 
 new 
@@ -2260,17 +2260,16 @@
 address)
-)
 ;%0A      
@@ -2449,23 +2449,15 @@
 is.p
-erson.setP
 hone
-(
+ = 
 new 
@@ -2468,17 +2468,16 @@
 e(phone)
-)
 ;%0A      
@@ -2656,24 +2656,16 @@
 his.
-person.setE
+e
 mail
-(
+ = 
 new 
@@ -2676,17 +2676,16 @@
 l(email)
-)
 ;%0A      
@@ -2753,19 +2753,53 @@
 urn 
-this.person
+new Person(name, phone, email, address, tags)
 ;%0A  

Update methods to not use Person’s setter methods