Getting the right conditional ConfigId Many conditions need to be scanned for the first one that matches a set of tests. If there is a matching condition, that conditions ConfigId should be returned.

I have a way to do the matching of conditions, but there are too many continue statements. Is there a better way to perform these checks?

private Integer match(List&lt;ConfitionEntity&gt; conditions, ActualDto actualDto) {

    if (CollectionUtils.isEmpty(conditions)) {
        return null;
    }
    Integer configId = null;
    for (ConfitionEntity condition : conditions) {
        boolean match = matchState(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchStatus(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchType(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchPre(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchMobile(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchAge(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchNumber(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchPassed(condition, actualDto);
        if (!match) {
            continue;
        }
        match = matchName(condition, actualDto);
        if (match) {
            configId = condition.getConfigId();
            break;
        }

    }
    return configId;
}
With the Java functional extensions you can "easily" encode these tests as a BinaryPredicate short-circuitung and set. See the documentation for The and method on BiPredicate.

Consider the following code which you can add-to as your conditions change:

private static final BiPredicate&lt;QueueMsgPushConditionEntity, QueueUpdatedDto&gt; MATCH = ((c, q) -&gt; c != null &amp;&amp; q != null)
    .and((c, q) -&gt; matchQueueState(c.getQueueState(), q.getState()))
    .and((c, q) -&gt; matchFirstPush(c.getFirstPush(), q.getSerialId())
    .and((c, q) -&gt; matchPushType(c.getPushType(), PushType.QUEUE_CALL))
    .......


Now, with that static lambda/functional expression, you can change your match function to look like:

private Integer match(List&lt;QueueMsgPushConditionEntity&gt; conditions, 
                      QueueUpdatedDto queueUpdatedDto) {

    Optional&lt;QueueMsgPushConditionEntity&gt; first = conditions.stream()
        .dropWhile(c -&gt; !MATCH.test(c, queueUpdatedDto))
        .findFirst();

    return first.map(c -&gt; c.getQueueMsgPushConfigId()).or(null);

}


What the above stream does, is go through all the conditions, and it throws them all away until it finds one that matches all the MATCH tests, and then it stops looking. If/when it finds one, it returns it as the Optional, which is mapped to the Integer, or null if nothing was found.