@Test public void testGetFinalId() { assertEquals("archive.war", BeanDeployments.getFinalId("archive__version-1-1.war", "__")); assertEquals("archive.war", BeanDeployments.getFinalId("archive..version-1-1.war", "..")); assertEquals("myApp", BeanDeployments.getFinalId("myApp..v1", "..")); assertEquals("myApp", BeanDeployments.getFinalId("myApp...v1", "...")); assertEquals("my.App", BeanDeployments.getFinalId("my.App..v1", "..")); assertEquals("my.App.jar", BeanDeployments.getFinalId("my.App..v1.jar", "..")); }
static String getFinalId(String beanArchiveId, String delimiter) { if (delimiter.isEmpty() || beanArchiveId.contains(EXTERNAL_ARCHIVE_DENOMINATOR)) { return beanArchiveId; } int idx = beanArchiveId.indexOf(delimiter); if (idx < 0) { return beanArchiveId; } String beforeDelimiter = beanArchiveId.substring(0, idx); int suffixIdx = beanArchiveId.lastIndexOf("."); if (suffixIdx + 1 == idx + delimiter.length()) { suffixIdx = -1; } return suffixIdx < 0 ? beforeDelimiter : beforeDelimiter + beanArchiveId.substring(suffixIdx, beanArchiveId.length()); }
BeanDeployments { static String getFinalId(String beanArchiveId, String delimiter) { if (delimiter.isEmpty() || beanArchiveId.contains(EXTERNAL_ARCHIVE_DENOMINATOR)) { return beanArchiveId; } int idx = beanArchiveId.indexOf(delimiter); if (idx < 0) { return beanArchiveId; } String beforeDelimiter = beanArchiveId.substring(0, idx); int suffixIdx = beanArchiveId.lastIndexOf("."); if (suffixIdx + 1 == idx + delimiter.length()) { suffixIdx = -1; } return suffixIdx < 0 ? beforeDelimiter : beforeDelimiter + beanArchiveId.substring(suffixIdx, beanArchiveId.length()); } }
BeanDeployments { static String getFinalId(String beanArchiveId, String delimiter) { if (delimiter.isEmpty() || beanArchiveId.contains(EXTERNAL_ARCHIVE_DENOMINATOR)) { return beanArchiveId; } int idx = beanArchiveId.indexOf(delimiter); if (idx < 0) { return beanArchiveId; } String beforeDelimiter = beanArchiveId.substring(0, idx); int suffixIdx = beanArchiveId.lastIndexOf("."); if (suffixIdx + 1 == idx + delimiter.length()) { suffixIdx = -1; } return suffixIdx < 0 ? beforeDelimiter : beforeDelimiter + beanArchiveId.substring(suffixIdx, beanArchiveId.length()); } private  BeanDeployments(); }
BeanDeployments { static String getFinalId(String beanArchiveId, String delimiter) { if (delimiter.isEmpty() || beanArchiveId.contains(EXTERNAL_ARCHIVE_DENOMINATOR)) { return beanArchiveId; } int idx = beanArchiveId.indexOf(delimiter); if (idx < 0) { return beanArchiveId; } String beforeDelimiter = beanArchiveId.substring(0, idx); int suffixIdx = beanArchiveId.lastIndexOf("."); if (suffixIdx + 1 == idx + delimiter.length()) { suffixIdx = -1; } return suffixIdx < 0 ? beforeDelimiter : beforeDelimiter + beanArchiveId.substring(suffixIdx, beanArchiveId.length()); } private  BeanDeployments();  }
BeanDeployments { static String getFinalId(String beanArchiveId, String delimiter) { if (delimiter.isEmpty() || beanArchiveId.contains(EXTERNAL_ARCHIVE_DENOMINATOR)) { return beanArchiveId; } int idx = beanArchiveId.indexOf(delimiter); if (idx < 0) { return beanArchiveId; } String beforeDelimiter = beanArchiveId.substring(0, idx); int suffixIdx = beanArchiveId.lastIndexOf("."); if (suffixIdx + 1 == idx + delimiter.length()) { suffixIdx = -1; } return suffixIdx < 0 ? beforeDelimiter : beforeDelimiter + beanArchiveId.substring(suffixIdx, beanArchiveId.length()); } private  BeanDeployments();   }