package com.atlassian.bitbucket.user;

import javax.annotation.Nonnull;

// note this class should not extend internal classes such as InternalNormalUser
// to enable its usage in the bundled plugins' tests.
public class TestApplicationUser implements ApplicationUser {

    private final int id;
    private final String emailAddress;
    private final String name;

    public TestApplicationUser(String name) {
        this(name, 0);
    }

    public TestApplicationUser(String name, int id) {
        this(name, id, name);
    }

    public TestApplicationUser(String name, int id, String emailAddress) {
        this.emailAddress = emailAddress;
        this.id = id;
        this.name = name;
    }

    @Override
    public <T> T accept(@Nonnull ApplicationUserVisitor<T> visitor) {
        return visitor.visit(this);
    }

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

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

    @Override
    public int getId() {
        return id;
    }

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

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

    @Nonnull
    @Override
    public UserType getType() {
        return UserType.NORMAL;
    }

    @Override
    public boolean isActive() {
        return true;
    }

    @Override
    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
    public boolean equals(Object o) {
        return ApplicationUserEquality.equals(this, o);
    }

    @Override
    public int hashCode() {
        return ApplicationUserEquality.hashCode(this);
    }
}
