public void doMatch ( ) { boolean matchFound = false ; for ( ConsumablePattern < T > pattern : patterns ) { if ( pattern . matches ( value ) ) { pattern . consume ( value ) ; matchFound = true ; break ; } } if ( ! matchFound ) { throw new MatchException ( "No match found for " + value ) ; } }
Runs through the possible matches and executes the specified consumer of the first match .