package carPooler.domain;

import java.util.Collections;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Traveler {

	// Initiate logger
	private static Logger logger = LoggerFactory.getLogger(Traveler.class);

	// Fields initialized at creation time
	private long _id;
	private String _email;
	private String _username;
	private Gender _gender;
	private GeoPosition _home;

	// Fields set after creation
	private GeoPosition _location;
	private Set<Traveler> _friends;

	public Traveler(long id,
			String email,
			String username,
			Gender gender,
			GeoPosition home) {
		this._id = id;
		this._email = email;
		this._username = username;
		this._gender = gender;
		this._home = home;
	}

	/**
	 * Adds the friend to your list so long as they are not already there.
	 * @param friend - User friend to add to the list.
	 */
	public void addFriend(Traveler friend) {
			if (!_friends.add(friend)) {
				logger.error("Friend, " + friend.getEmail() + " not added to " + this._email);
			}
	}

	public long getId() {
		return _id;
	}

	public String getEmail() {
		return _email;
	}

	public String getName() {
		return _username;
	}

	public Gender getGender() {
		return _gender;
	}

	public GeoPosition getHome() {
		return _home;
	}

	public GeoPosition getLocation() {
		return _location;
	}

	public Set<Traveler> getFriends() {
		return Collections.unmodifiableSet(_friends);
	}

	// Setters

	public void setID(long id) {
		this._id = id;
	}

	public void setHome(GeoPosition home) {
		this._home = home;
	}

	public void setUsername(String name) {
		this._username = name;
	}

	public void setLocation(GeoPosition location) {
		this._location = location;
	}

//	@Override
//	public boolean equals(Object o) {
//		if (((Traveler) o).getEmail().equals(this._email)) {
//			return true;
//		} else {
//			return false;
//		}
//	}
}

@@ -559,21 +559,17 @@
 long id,
-%0D%0A%09%09%09
+ 
 String e
@@ -573,21 +573,17 @@
 g email,
-%0D%0A%09%09%09
+ 
 String u
@@ -590,21 +590,17 @@
 sername,
-%0D%0A%09%09%09
+ 
 Gender g
@@ -605,21 +605,17 @@
  gender,
-%0D%0A%09%09%09
+ 
 GeoPosit
@@ -840,21 +840,87 @@
 %09 * 
-@param friend
+Relies on the equals(Traveler t) method%0D%0A%09 *%0D%0A%09 * @param friend%0D%0A%09 *           
  - U
@@ -1000,17 +1000,16 @@
 end) %7B%0D%0A
-%09
 %09%09if (!_
@@ -1035,17 +1035,16 @@
 ) %7B%0D%0A%09%09%09
-%09
 logger.e
@@ -1115,17 +1115,16 @@
 mail);%0D%0A
-%09
 %09%09%7D%0D%0A%09%7D%0D
@@ -1846,18 +1846,16 @@
 %0D%0A%09%7D%0D%0A%0D%0A
-//
 %09@Overri
@@ -1858,18 +1858,16 @@
 erride%0D%0A
-//
 %09public 
@@ -1893,73 +1893,97 @@
 ct o
+bj
 ) %7B%0D%0A
-//
 %09%09if (
-((Traveler) o).getEmail().equals(this._email)
+!(obj instanceof Traveler)) %7B%0D%0A%09%09%09return false;%0D%0A%09%09%7D%0D%0A%09%09if (obj == this
 ) %7B%0D%0A
-//
 %09%09%09r
@@ -1999,51 +1999,82 @@
 e;%0D%0A
-//
 %09%09%7D
- else %7B%0D%0A//%09%09%09return false;%0D%0A//%09%09%7D%0D%0A//
+%0D%0A%09%09Traveler other = (Traveler) obj;%0D%0A%09%09return this._id == other._id;%0D%0A
 %09%7D%0D%0A

Create Traveler.equals(Object obj) method