@Test public void packageNameToCamelCase_withInvalidPackage_shouldSuccessfullyReturn() { assertThat(EncodableProcessor.packageNameToCamelCase("com.example.")).isEqualTo("ComExample"); }
@VisibleForTesting static String packageNameToCamelCase(String packageName) { if (packageName.isEmpty()) { return packageName; } packageName = Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1); int dotIndex = packageName.indexOf('.'); while (dotIndex > -1) { String prefix = packageName.substring(0, dotIndex); String suffix = ""; if (dotIndex < packageName.length() - 1) { suffix = Character.toUpperCase(packageName.charAt(dotIndex + 1)) + (dotIndex < packageName.length() - 2 ? packageName.substring(dotIndex + 2) : ""); } packageName = prefix + suffix; dotIndex = packageName.indexOf('.'); } return packageName; }
EncodableProcessor extends AbstractProcessor { @VisibleForTesting static String packageNameToCamelCase(String packageName) { if (packageName.isEmpty()) { return packageName; } packageName = Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1); int dotIndex = packageName.indexOf('.'); while (dotIndex > -1) { String prefix = packageName.substring(0, dotIndex); String suffix = ""; if (dotIndex < packageName.length() - 1) { suffix = Character.toUpperCase(packageName.charAt(dotIndex + 1)) + (dotIndex < packageName.length() - 2 ? packageName.substring(dotIndex + 2) : ""); } packageName = prefix + suffix; dotIndex = packageName.indexOf('.'); } return packageName; } }
EncodableProcessor extends AbstractProcessor { @VisibleForTesting static String packageNameToCamelCase(String packageName) { if (packageName.isEmpty()) { return packageName; } packageName = Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1); int dotIndex = packageName.indexOf('.'); while (dotIndex > -1) { String prefix = packageName.substring(0, dotIndex); String suffix = ""; if (dotIndex < packageName.length() - 1) { suffix = Character.toUpperCase(packageName.charAt(dotIndex + 1)) + (dotIndex < packageName.length() - 2 ? packageName.substring(dotIndex + 2) : ""); } packageName = prefix + suffix; dotIndex = packageName.indexOf('.'); } return packageName; }  }
EncodableProcessor extends AbstractProcessor { @VisibleForTesting static String packageNameToCamelCase(String packageName) { if (packageName.isEmpty()) { return packageName; } packageName = Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1); int dotIndex = packageName.indexOf('.'); while (dotIndex > -1) { String prefix = packageName.substring(0, dotIndex); String suffix = ""; if (dotIndex < packageName.length() - 1) { suffix = Character.toUpperCase(packageName.charAt(dotIndex + 1)) + (dotIndex < packageName.length() - 2 ? packageName.substring(dotIndex + 2) : ""); } packageName = prefix + suffix; dotIndex = packageName.indexOf('.'); } return packageName; }  @Override SourceVersion getSupportedSourceVersion(); @Override synchronized void init(ProcessingEnvironment processingEnvironment); @Override boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment); }
EncodableProcessor extends AbstractProcessor { @VisibleForTesting static String packageNameToCamelCase(String packageName) { if (packageName.isEmpty()) { return packageName; } packageName = Character.toUpperCase(packageName.charAt(0)) + packageName.substring(1); int dotIndex = packageName.indexOf('.'); while (dotIndex > -1) { String prefix = packageName.substring(0, dotIndex); String suffix = ""; if (dotIndex < packageName.length() - 1) { suffix = Character.toUpperCase(packageName.charAt(dotIndex + 1)) + (dotIndex < packageName.length() - 2 ? packageName.substring(dotIndex + 2) : ""); } packageName = prefix + suffix; dotIndex = packageName.indexOf('.'); } return packageName; }  @Override SourceVersion getSupportedSourceVersion(); @Override synchronized void init(ProcessingEnvironment processingEnvironment); @Override boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment);  }