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.
	 * Relies on the equals(Traveler t) method
	 *
	 * @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 obj) {
		if (!(obj instanceof Traveler)) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		Traveler other = (Traveler) obj;
		return this._id == other._id;
	}
}

@@ -74,24 +74,82 @@
 til.Set;%0D%0A%0D%0A
+import org.apache.commons.lang3.builder.HashCodeBuilder;%0D%0A
 import org.s
@@ -980,19 +980,16 @@
   - 
-User friend
+Traveler
  to 
@@ -999,16 +999,24 @@
  to the 
+friends 
 list.%0D%0A%09
@@ -2135,12 +2135,120 @@
 id;%0D%0A%09%7D%0D
+%0A%0D%0A%09@Override%0D%0A%09public int hashCode() %7B%0D%0A%09%09return new HashCodeBuilder(17, 31).append(_id).toHashCode();%0D%0A%09%7D%0D
 %0A%7D%0D%0A

Add hash code method