Multiple if conditions in one block - looking for faster and more efficient code
First of all, your formatting seems messy, please fix it.



Did you rip it out or is there really zero documentation in there (JavaDoc)? Consider adding some, it will make your life and that of others easier.



First step would be to add an overload to match() which accepts two strings, like this:

private boolean match(Context messageContext, ContextRule contextRule) {
    return match(contextRule.getMessageContext().getUser(), messageContext.getUser())
            &amp;&amp; match(contextRule.getMessageContext().getApplication(), messageContext.getApplication())
            &amp;&amp; match(contextRule.getMessageContext().getService(), messageContext.getService())
            &amp;&amp; match(contextRule.getMessageContext().getOperation(), messageContext.getOperation());
}

private boolean match(String value, String contextValue) {
    return value.equals(ContextRuleEvaluator.WILDCARD) || value.equals(contextValue);
}


This makes it already a lot easier to read. Naming of the variables is a little bit suboptimal, that's because I could not come up with better names right now.



Ultimately you should see if you can't extend and change Context to contain a match() function. This would require to change Context into an abstract class, so it might not be possible.

public abstract class Context {

    public abstract String getUser();

    public abstract void setUser(String user);

    public abstract String getApplication();

    public abstract void setApplication(String application);

    public abstract String getService();

    public abstract void setService(String service);

    public abstract String getOperation();

    public abstract void setOperation(String operation);

    /**
     * Matches this context against the given Context.
     *
     * @param context
     * @return
     */
    public boolean match(Context context) {
        return match(getUser(), context.getUser())
                &amp;&amp; match(getApplication(), context.getApplication())
                &amp;&amp; match(getService(), context.getService())
                &amp;&amp; match(getOperation(), context.getOperation());
    }

    private boolean match(String value, String otherValue) {
        return value.equals(ContextRuleEvaluator.WILDCARD) || value.equals(otherValue);
    }
}


That would allow you to do this in your code:

return contextRule.getMessageContext().match(messageContext);


Which is very readable, even if you don't pack it into a function but call it directly.