public Optional < Character > character ( ) { char c = 0 ; int count = 0 ; for ( int i = 0 ; i < members . length ; ++ i ) { if ( members [ i ] ) { c = ( char ) i ; ++ count ; } } return ( count == 1 ) ? Optional . of ( c ) : Optional . empty ( ) ; }
If this set matches a single character then return an optional with that character . Otherwise return an empty optional .