@Test public void ensureValidKeyTest() { String[] validKeys = new String[]{ "", "1", "ab", "ab1", "b-c", "d_e", "pilosa.com", "bbf8d41c-7dba-40c4-94dc-94677b43bcf3", "{bbf8d41c-7dba-40c4-94dc-94677b43bcf3}", "https%3A "aHR0cHM6Ly93d3cucGlsb3NhLmNvbS9hYm91dC8jY29udGFjdA==", "urn:isbn:1234567", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }; for (String key : validKeys) { Validator.ensureValidKey(key); } }
public static void ensureValidKey(String key) { if (!validKey(key)) { throw new ValidationException(String.format("Invalid key: %s", key)); } }
Validator { public static void ensureValidKey(String key) { if (!validKey(key)) { throw new ValidationException(String.format("Invalid key: %s", key)); } } }
Validator { public static void ensureValidKey(String key) { if (!validKey(key)) { throw new ValidationException(String.format("Invalid key: %s", key)); } } Validator(); }
Validator { public static void ensureValidKey(String key) { if (!validKey(key)) { throw new ValidationException(String.format("Invalid key: %s", key)); } } Validator(); @SuppressWarnings("WeakerAccess") static boolean validIndexName(String indexName); static void ensureValidIndexName(String indexName); @SuppressWarnings("WeakerAccess") static boolean validFieldName(String fieldName); static void ensureValidFieldName(String fieldName); @SuppressWarnings("WeakerAccess") static boolean validLabel(String label); static void ensureValidLabel(String label); @SuppressWarnings("WeakerAccess") static boolean validKey(String key); static void ensureValidKey(String key); }
Validator { public static void ensureValidKey(String key) { if (!validKey(key)) { throw new ValidationException(String.format("Invalid key: %s", key)); } } Validator(); @SuppressWarnings("WeakerAccess") static boolean validIndexName(String indexName); static void ensureValidIndexName(String indexName); @SuppressWarnings("WeakerAccess") static boolean validFieldName(String fieldName); static void ensureValidFieldName(String fieldName); @SuppressWarnings("WeakerAccess") static boolean validLabel(String label); static void ensureValidLabel(String label); @SuppressWarnings("WeakerAccess") static boolean validKey(String key); static void ensureValidKey(String key);  }