code/app/be/objectify/deadbolt/java/DeadboltAnalyzer.java
public boolean hasAllRoles(final Optional<? extends Subject> subjectOption,
                               final String[] roleNames)
    {
        final List<String> heldRoles = getRoleNames(subjectOption);

        boolean roleCheckResult = roleNames != null && roleNames.length > 0;
        for (int i = 0; roleCheckResult && i < roleNames.length; i++)
        {
            boolean invert = false;
            String roleName = roleNames[i];
            if (roleName.startsWith("!"))
            {
                invert = true;
                roleName = roleName.substring(1);
            }
            roleCheckResult = heldRoles.contains(roleName);

            if (invert)
            {
                roleCheckResult = !roleCheckResult;
            }
        }
        return roleCheckResult;
    }
public boolean hasAllRoles(final Optional<? extends Subject> subjectOption,
                               final String[] roleNames)
    {
        final List<String> heldRoles = getRoleNames(subjectOption);

        boolean roleCheckResult = roleNames != null && roleNames.length > 0;
        for (int i = 0; roleCheckResult && i < roleNames.length; i++)
        {
            boolean invert = false;
            String roleName = roleNames[i];
            if (roleName.startsWith("!"))
            {
                invert = true;
                roleName = roleName.substring(1);
            }
            roleCheckResult = heldRoles.contains(roleName);

            if (invert)
            {
                roleCheckResult = !roleCheckResult;
            }
        }
        return roleCheckResult;
    }
public boolean hasAllRoles ( final Optional < ? extends Subject > subjectOption , final String [ ] roleNames ) { final List < String > heldRoles = getRoleNames ( subjectOption ) ; boolean roleCheckResult = roleNames != null && roleNames . length > 0 ; for ( int i = 0 ; roleCheckResult && i < roleNames . length ; i ++ ) { boolean invert = false ; String roleName = roleNames [ i ] ; if ( roleName . startsWith ( "!" ) ) { invert = true ; roleName = roleName . substring ( 1 ) ; } roleCheckResult = heldRoles . contains ( roleName ) ; if ( invert ) { roleCheckResult = ! roleCheckResult ; } } return roleCheckResult ; }
Check if the {@link Subject} has all the roles given in the roleNames array.  Note that while a Subject must
have all the roles, it may also have other roles.

@param subjectOption an option for the subject
@param roleNames     the names of the required roles
@return true iff the subject has all the roles
Check if the { @link Subject } has all the roles given in the roleNames array . Note that while a Subject must have all the roles it may also have other roles .