@Test public void givenAPackageNameWithAtLeastTwoFieldsSeparatedByASingleDot_whenIsAValidPackageName_thenReturnTrue() { boolean isAValidPackageName = isAValidPackageName(TEST_VALID_PACKAGE_NAME_WITH_TWO_FIELDS); assertTrue(isAValidPackageName); }
public static boolean isAValidPackageName(@NonNull String candidatePackageName) { checkNotNull(candidatePackageName, "The candidate package name must not be null"); if (candidatePackageName.isEmpty()) return false; if (candidatePackageName.endsWith(".")) return false; String[] packageNameFields = candidatePackageName.split(DOT_AS_REGULAR_EXPRESSION); if (packageNameFields.length < MINIMUM_NUMBER_OF_FIELDS_IN_A_PACKAGE_NAME) { return false; } for (String packageNameField : packageNameFields) { if (packageNameField.isEmpty()) { return false; } } return true; }
PackageNameHelper { public static boolean isAValidPackageName(@NonNull String candidatePackageName) { checkNotNull(candidatePackageName, "The candidate package name must not be null"); if (candidatePackageName.isEmpty()) return false; if (candidatePackageName.endsWith(".")) return false; String[] packageNameFields = candidatePackageName.split(DOT_AS_REGULAR_EXPRESSION); if (packageNameFields.length < MINIMUM_NUMBER_OF_FIELDS_IN_A_PACKAGE_NAME) { return false; } for (String packageNameField : packageNameFields) { if (packageNameField.isEmpty()) { return false; } } return true; } }
PackageNameHelper { public static boolean isAValidPackageName(@NonNull String candidatePackageName) { checkNotNull(candidatePackageName, "The candidate package name must not be null"); if (candidatePackageName.isEmpty()) return false; if (candidatePackageName.endsWith(".")) return false; String[] packageNameFields = candidatePackageName.split(DOT_AS_REGULAR_EXPRESSION); if (packageNameFields.length < MINIMUM_NUMBER_OF_FIELDS_IN_A_PACKAGE_NAME) { return false; } for (String packageNameField : packageNameFields) { if (packageNameField.isEmpty()) { return false; } } return true; }  }
PackageNameHelper { public static boolean isAValidPackageName(@NonNull String candidatePackageName) { checkNotNull(candidatePackageName, "The candidate package name must not be null"); if (candidatePackageName.isEmpty()) return false; if (candidatePackageName.endsWith(".")) return false; String[] packageNameFields = candidatePackageName.split(DOT_AS_REGULAR_EXPRESSION); if (packageNameFields.length < MINIMUM_NUMBER_OF_FIELDS_IN_A_PACKAGE_NAME) { return false; } for (String packageNameField : packageNameFields) { if (packageNameField.isEmpty()) { return false; } } return true; }  static boolean isAValidPackageName(@NonNull String candidatePackageName); static URL revertPackageNameToURL(@NonNull String candidatePackageName); }
PackageNameHelper { public static boolean isAValidPackageName(@NonNull String candidatePackageName) { checkNotNull(candidatePackageName, "The candidate package name must not be null"); if (candidatePackageName.isEmpty()) return false; if (candidatePackageName.endsWith(".")) return false; String[] packageNameFields = candidatePackageName.split(DOT_AS_REGULAR_EXPRESSION); if (packageNameFields.length < MINIMUM_NUMBER_OF_FIELDS_IN_A_PACKAGE_NAME) { return false; } for (String packageNameField : packageNameFields) { if (packageNameField.isEmpty()) { return false; } } return true; }  static boolean isAValidPackageName(@NonNull String candidatePackageName); static URL revertPackageNameToURL(@NonNull String candidatePackageName);  }