@Test(expected = IllegalArgumentException.class) public void testCreateJavaName_StringWithPrefixAndPostfix_Bug() { System.out.println("testCreateJavaName_StringWithPrefixAndPostfix"); String dbName = "CUS_CUSTOMER"; ModelBuilder instance = new ModelBuilder(null, ENGINE_CONF, new PostgreSql9ModelBuilderConfig(), new LocalisedMessages("messages", null)); instance.createJavaName(dbName, true, true, true); }
final protected String createJavaName(String dbName, boolean firstCharToUpperCase, boolean hasPrefix, boolean hasPostFix) { String result = ""; if (dbName.contains("_")) { String[] sArray = dbName.toLowerCase().split("_"); for (int i = 0; i < sArray.length; i++) { String s = sArray[i]; if (hasPrefix && i == 0) { continue; } if (hasPostFix && i == sArray.length - 1) { continue; } if (i > 0) { s = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, s); } result += s; } } else { result = dbName.toLowerCase(); } if (result.length() < 1) { throw new IllegalArgumentException(String.format("Object name \"%s\" does not comply with the specified configuration: hasPrefix=%s, hasPostFix=%s", dbName, hasPrefix, hasPostFix)); } if (Character.isDigit(result.charAt(0))) { result = "X" + result; } if (isRestrictedWord(result.toLowerCase())) { result = "X" + result; } if (firstCharToUpperCase) { result = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, result); } else { result = changeFirstCharTo(CHAR_CASE_TYPE.LOWERCASE, result); } return result; }
ModelBuilder { final protected String createJavaName(String dbName, boolean firstCharToUpperCase, boolean hasPrefix, boolean hasPostFix) { String result = ""; if (dbName.contains("_")) { String[] sArray = dbName.toLowerCase().split("_"); for (int i = 0; i < sArray.length; i++) { String s = sArray[i]; if (hasPrefix && i == 0) { continue; } if (hasPostFix && i == sArray.length - 1) { continue; } if (i > 0) { s = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, s); } result += s; } } else { result = dbName.toLowerCase(); } if (result.length() < 1) { throw new IllegalArgumentException(String.format("Object name \"%s\" does not comply with the specified configuration: hasPrefix=%s, hasPostFix=%s", dbName, hasPrefix, hasPostFix)); } if (Character.isDigit(result.charAt(0))) { result = "X" + result; } if (isRestrictedWord(result.toLowerCase())) { result = "X" + result; } if (firstCharToUpperCase) { result = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, result); } else { result = changeFirstCharTo(CHAR_CASE_TYPE.LOWERCASE, result); } return result; } }
ModelBuilder { final protected String createJavaName(String dbName, boolean firstCharToUpperCase, boolean hasPrefix, boolean hasPostFix) { String result = ""; if (dbName.contains("_")) { String[] sArray = dbName.toLowerCase().split("_"); for (int i = 0; i < sArray.length; i++) { String s = sArray[i]; if (hasPrefix && i == 0) { continue; } if (hasPostFix && i == sArray.length - 1) { continue; } if (i > 0) { s = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, s); } result += s; } } else { result = dbName.toLowerCase(); } if (result.length() < 1) { throw new IllegalArgumentException(String.format("Object name \"%s\" does not comply with the specified configuration: hasPrefix=%s, hasPostFix=%s", dbName, hasPrefix, hasPostFix)); } if (Character.isDigit(result.charAt(0))) { result = "X" + result; } if (isRestrictedWord(result.toLowerCase())) { result = "X" + result; } if (firstCharToUpperCase) { result = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, result); } else { result = changeFirstCharTo(CHAR_CASE_TYPE.LOWERCASE, result); } return result; } ModelBuilder(Connection con,
            EngineConfiguration engineConf,
            IModelBuilderConfig config,
            LocalisedMessages messages); }
ModelBuilder { final protected String createJavaName(String dbName, boolean firstCharToUpperCase, boolean hasPrefix, boolean hasPostFix) { String result = ""; if (dbName.contains("_")) { String[] sArray = dbName.toLowerCase().split("_"); for (int i = 0; i < sArray.length; i++) { String s = sArray[i]; if (hasPrefix && i == 0) { continue; } if (hasPostFix && i == sArray.length - 1) { continue; } if (i > 0) { s = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, s); } result += s; } } else { result = dbName.toLowerCase(); } if (result.length() < 1) { throw new IllegalArgumentException(String.format("Object name \"%s\" does not comply with the specified configuration: hasPrefix=%s, hasPostFix=%s", dbName, hasPrefix, hasPostFix)); } if (Character.isDigit(result.charAt(0))) { result = "X" + result; } if (isRestrictedWord(result.toLowerCase())) { result = "X" + result; } if (firstCharToUpperCase) { result = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, result); } else { result = changeFirstCharTo(CHAR_CASE_TYPE.LOWERCASE, result); } return result; } ModelBuilder(Connection con,
            EngineConfiguration engineConf,
            IModelBuilderConfig config,
            LocalisedMessages messages); final void build(); List<Table> getTableList(); List<Index> getIndexListForTable(Table table); }
ModelBuilder { final protected String createJavaName(String dbName, boolean firstCharToUpperCase, boolean hasPrefix, boolean hasPostFix) { String result = ""; if (dbName.contains("_")) { String[] sArray = dbName.toLowerCase().split("_"); for (int i = 0; i < sArray.length; i++) { String s = sArray[i]; if (hasPrefix && i == 0) { continue; } if (hasPostFix && i == sArray.length - 1) { continue; } if (i > 0) { s = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, s); } result += s; } } else { result = dbName.toLowerCase(); } if (result.length() < 1) { throw new IllegalArgumentException(String.format("Object name \"%s\" does not comply with the specified configuration: hasPrefix=%s, hasPostFix=%s", dbName, hasPrefix, hasPostFix)); } if (Character.isDigit(result.charAt(0))) { result = "X" + result; } if (isRestrictedWord(result.toLowerCase())) { result = "X" + result; } if (firstCharToUpperCase) { result = changeFirstCharTo(CHAR_CASE_TYPE.UPPERCASE, result); } else { result = changeFirstCharTo(CHAR_CASE_TYPE.LOWERCASE, result); } return result; } ModelBuilder(Connection con,
            EngineConfiguration engineConf,
            IModelBuilderConfig config,
            LocalisedMessages messages); final void build(); List<Table> getTableList(); List<Index> getIndexListForTable(Table table);  }