package apz.pirichat.server;
import apz.pirichat.shared.PiriException;
import apz.pirichat.shared.PiriZeroLengthException;

public class User
{
    public static enum Group { GROUP_DEFAULT, GROUP_MOD, GROUP_ADMIN };

    private String mUserName;
    private String mDisplayName;
    private String mPassword;
    private Group mGroup;

    public User(String pUserName, String pDisplayName, String pPassword, Group pGroup) throws PiriZeroLengthException
    {
        if (pUserName.length() == 0)
            throw new PiriZeroLengthException("pUserName");
        if (pDisplayName.length() == 0)
            throw new PiriZeroLengthException("pDisplayName");
        if (pPassword.length() == 0)
            throw new PiriZeroLengthException("pPassword");
        mUserName = pUserName;
        mDisplayName = pDisplayName;
        mPassword = pPassword;
        mGroup = pGroup;
    }

    public String getUserName()
    {
        return mUserName;
    }

    public String getDisplayName()
    {
        return mDisplayName;
    }

    public void setDisplayName(String pDisplayName) throws PiriZeroLengthException
    {
        if (pDisplayName.length() == 0)
            throw new PiriZeroLengthException("pDisplayName");
        mDisplayName = pDisplayName;
    }

    public boolean checkPassword(String pPassword)
    {
        return mPassword.equals(pPassword);
    }

    public void setPassword(String pPassword) throws PiriZeroLengthException
    {
        if (pPassword.length() == 0)
            throw new PiriZeroLengthException("pPassword");
        mPassword = pPassword;
    }

    public Group getGroup()
    {
        return mGroup;
    }

    public void setGroup(Group pGroup)
    {
        mGroup = pGroup;
    }
}
