package com.atlassian.bitbucket.user;

import com.google.common.base.Objects;

import javax.annotation.Nonnull;
import java.io.Serializable;

public class SimplePerson implements Person, Serializable {

    private final String email;
    private final String name;

    public SimplePerson(String name, String email) {
        this.email = email;
        this.name = name;
    }

    @Override
    public String getEmailAddress() {
        return email;
    }

    @Nonnull
    @Override
    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        SimplePerson that = (SimplePerson) o;
        return Objects.equal(getName(), that.getName()) &&
                Objects.equal(getEmailAddress(), that.getEmailAddress());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getName(), getEmailAddress());
    }

    @Override
    public String toString() {
        return "SimplePerson{" +
                "name='" + getName() + '\'' +
                ", email='" + getEmailAddress() + '\'' +
                '}';
    }
}
