public @CheckForNull Block createNewBlock(@Nonnull String systemName,@CheckForNull String userName) throws IllegalArgumentException {
  Block r;
  if (userName != null && !userName.equals("")) {
    r=getByUserName(userName);
    if (r != null) {
      return null;
    }
  }
  r=getBySystemName(systemName);
  if (r != null) {
    return null;
  }
  String sName=systemName.toUpperCase();
  r=new Block(sName,userName);
  register(r);
  if (systemName.startsWith("IB:AUTO:")) {
    try {
      int autoNumber=Integer.parseInt(systemName.substring(8));
      if (autoNumber > lastAutoBlockRef) {
        lastAutoBlockRef=autoNumber;
      }
    }
 catch (    NumberFormatException e) {
      log.warn("Auto generated SystemName " + systemName + " is not in the correct format");
    }
  }
  try {
    r.setBlockSpeed("Global");
  }
 catch (  jmri.JmriException ex) {
    log.error(ex.toString());
  }
  return r;
}

public @ CheckForNull Block createNewBlock ( @ Nonnull String systemName , @ CheckForNull String userName ) throws IllegalArgumentException { Block r ; if ( userName != null && ! userName . equals ( "" ) ) { r = getByUserName ( userName ) ; if ( r != null ) { return null ; } } r = getBySystemName ( systemName ) ; if ( r != null ) { return null ; } String sName = systemName . toUpperCase ( ) ; r = new Block ( sName , userName ) ; register ( r ) ; if ( systemName . startsWith ( "IB:AUTO:" ) ) { try { int autoNumber = Integer . parseInt ( systemName . substring ( 8 ) ) ; if ( autoNumber > lastAutoBlockRef ) { lastAutoBlockRef = autoNumber ; } } catch ( NumberFormatException e ) { log . warn ( "Auto generated SystemName " + systemName + " is not in the correct format" ) ; } } try { r . setBlockSpeed ( "Global" ) ; } catch ( jmri . JmriException ex ) { log . error ( ex . toString ( ) ) ; } return r ; }
method to create a new block only if it does not exist
