@ Override public Status match ( int cc ) { int highest = - 1 ; Iterator < Matcher > iterator = active . iterator ( ) ; while ( iterator . hasNext ( ) ) { Matcher matcher = iterator . next ( ) ; Status s = matcher . match ( cc ) ; highest = Math . max ( highest , s . ordinal ( ) ) ; switch ( s ) { case Match : lastMatched = matcher ; clear ( ) ; return s ; case WillMatch : lastMatched = matcher ; return s ; case Error : iterator . remove ( ) ; break ; } } if ( active . isEmpty ( ) ) { clear ( ) ; return Status . Error ; } return Status . values ( ) [ highest ] ; }
If one matches returns Match . If all return Error returns error . Otherwise returns Ok .