package com.atlassian.bitbucket.web.conditions;

import com.atlassian.plugin.PluginParseException;
import com.atlassian.plugin.web.Condition;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserType;

import java.util.Map;

/**
 * @deprecated in 4.1 for removal in 5.0. Use {@link IsUserOfTypeCondition IsUserOfTypeCondition} instead.
 */
public class IsNormalUserCondition implements Condition {
    @Override
    public void init(Map<String, String> params) throws PluginParseException {
    }

    @Override
    public boolean shouldDisplay(Map<String, Object> context) {
        Object user = context.get("user");
        return user instanceof ApplicationUser && ((ApplicationUser) user).getType() == UserType.NORMAL;
    }
}
