public boolean hasRole(String role) {
        if (role != null && roles != null) {
            for (Role r : roles) {
                if (r != null && r.name != null && r.name.toLowerCase().equalsIgnoreCase(role.toLowerCase())) {
                    return true;
                }
            }
        }
        return false;
    }