public String generateName(final IntUnaryOperator randomInRange,final int length,final char startingSymbol){
  if (length == 0) {
    return "LENGTH_WAS_ZERO";
  }
  final StringBuilder sb=new StringBuilder();
  sb.append(startingSymbol);
  while (sb.length() < length) {
    for (int i=0; i < sb.length(); i++) {
      final char currentChar=sb.charAt(i);
      final boolean isCurrentCharUpperCase=Character.isUpperCase(currentChar);
      if (isCurrentCharUpperCase) {
        final String substitution=chooseRandomRuleOption(randomInRange,currentChar);
        if (substitution != null) {
          String temp=sb.toString();
          temp=temp.replace(String.valueOf(currentChar),substitution);
          sb.setLength(0);
          sb.append(temp);
          i--;
        }
      }
    }
    if (sb.length() < length) {
      sb.setLength(0);
      sb.append(startingSymbol);
    }
  }
  if (length >= 0) {
    return sb.substring(0,length);
  }
 else {
    return sb.toString();
  }
}

public String generateName ( final IntUnaryOperator randomInRange , final int length , final char startingSymbol ) { if ( length == 0 ) { return "LENGTH_WAS_ZERO" ; } final StringBuilder sb = new StringBuilder ( ) ; sb . append ( startingSymbol ) ; while ( sb . length ( ) < length ) { for ( int i = 0 ; i < sb . length ( ) ; i ++ ) { final char currentChar = sb . charAt ( i ) ; final boolean isCurrentCharUpperCase = Character . isUpperCase ( currentChar ) ; if ( isCurrentCharUpperCase ) { final String substitution = chooseRandomRuleOption ( randomInRange , currentChar ) ; if ( substitution != null ) { String temp = sb . toString ( ) ; temp = temp . replace ( String . valueOf ( currentChar ) , substitution ) ; sb . setLength ( 0 ) ; sb . append ( temp ) ; i -- ; } } } if ( sb . length ( ) < length ) { sb . setLength ( 0 ) ; sb . append ( startingSymbol ) ; } } if ( length >= 0 ) { return sb . substring ( 0 , length ) ; } else { return sb . toString ( ) ; } }
searches the rules of the grammar for the first rule whose first character matches that of the specified character . ex : character = ' s ' rule = " t tt tt " rule = " s ss ss " rule = " s tt st " the first rule is ignored and the second rule is used .
