@Test public void testValidUrls() { for (DatabaseVendor databaseVendor : TO_TEST) { String jdbcUrl = "jdbc:" + databaseVendor.jdbcUrlDriverId() + ":etc"; Optional<DatabaseVendor> foundVendor = underTest.getVendorByJdbcUrl(jdbcUrl); assertFalse(foundVendor.isEmpty()); assertEquals("Expected " + databaseVendor + " but got " + foundVendor.get(), databaseVendor, foundVendor.get()); } }
public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); }
DatabaseVendorUtil { public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); } }
DatabaseVendorUtil { public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); }  }
DatabaseVendorUtil { public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); }  Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl); }
DatabaseVendorUtil { public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); }  Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl);  }