code: static String resolveDuplicateName(String name){
  
          if(name.matches("^copy\\d+\\..*$")){ // If true - means bean name already contain copy prefix
  
              // Parsing copy number from prefix to increase it
  
              // Copy number contains in the prefix end -
              // StringBuilder is required to reverse string
              StringBuilder copyPrefix =
                      new StringBuilder(
                              name.substring(0, name.indexOf('.'))
                      );
  
              // Collects copy number digits
              StringBuilder copyNumber = new StringBuilder();
  
              // Reverting copy prefix and collecting digits
              for(Character prefixChar : copyPrefix.reverse().toString().toCharArray())
                  if(Character.isDigit(prefixChar))
                      copyNumber.append(prefixChar);
                  else break; // loop reach end of 'copy' word. No copy number digits left
  
              return "copy" +
                      // Parsing copy number to integer and increase it
                      String.valueOf(
                              Integer.parseInt(
                                      // Digits are collected in reverse order, reverse it again
                                      copyNumber.reverse().toString()
                              ) + 1
                      ) + "." +
                      name.substring(name.indexOf('.') + 1); // Remove old prefix
  
          }
          else
              return "copy1." + name;
  
      }
docs: /* for testing