@Test void testGetWithCustomRegisteredTypeSettersWhenMultipleMatchingTypeSetters() { List<DatabaseTypeSetter> registeredDatabaseTypeSetters = List.of(new BooleanDatabaseTypeSetter(), new BooleanDatabaseTypeSetter()); DatabaseTypeSetterFactory databaseTypeSetterFactory = new DatabaseTypeSetterFactory(registeredDatabaseTypeSetters); Assertions.assertThrows(IllegalStateException.class, () -> databaseTypeSetterFactory.get(BOOL_TYPE)); }
public DatabaseTypeSetter get(String databaseType) { List<DatabaseTypeSetter> matchingTypeSetters = registeredTypeSetters.stream() .filter(typeSetter -> containsIgnoreCase(databaseType, typeSetter)) .collect(Collectors.toList()); if (matchingTypeSetters.isEmpty()) { throw new IllegalStateException(MessageFormat.format("No database type setter is defined for type \"{0}\"", databaseType)); } if (matchingTypeSetters.size() > 1) { throw new IllegalStateException(MessageFormat.format("More than one database type setters are defined for type \"{0}\"", databaseType)); } return matchingTypeSetters.get(0); }
DatabaseTypeSetterFactory { public DatabaseTypeSetter get(String databaseType) { List<DatabaseTypeSetter> matchingTypeSetters = registeredTypeSetters.stream() .filter(typeSetter -> containsIgnoreCase(databaseType, typeSetter)) .collect(Collectors.toList()); if (matchingTypeSetters.isEmpty()) { throw new IllegalStateException(MessageFormat.format("No database type setter is defined for type \"{0}\"", databaseType)); } if (matchingTypeSetters.size() > 1) { throw new IllegalStateException(MessageFormat.format("More than one database type setters are defined for type \"{0}\"", databaseType)); } return matchingTypeSetters.get(0); } }
DatabaseTypeSetterFactory { public DatabaseTypeSetter get(String databaseType) { List<DatabaseTypeSetter> matchingTypeSetters = registeredTypeSetters.stream() .filter(typeSetter -> containsIgnoreCase(databaseType, typeSetter)) .collect(Collectors.toList()); if (matchingTypeSetters.isEmpty()) { throw new IllegalStateException(MessageFormat.format("No database type setter is defined for type \"{0}\"", databaseType)); } if (matchingTypeSetters.size() > 1) { throw new IllegalStateException(MessageFormat.format("More than one database type setters are defined for type \"{0}\"", databaseType)); } return matchingTypeSetters.get(0); } DatabaseTypeSetterFactory();  DatabaseTypeSetterFactory(List<DatabaseTypeSetter> registeredTypeSetters); }
DatabaseTypeSetterFactory { public DatabaseTypeSetter get(String databaseType) { List<DatabaseTypeSetter> matchingTypeSetters = registeredTypeSetters.stream() .filter(typeSetter -> containsIgnoreCase(databaseType, typeSetter)) .collect(Collectors.toList()); if (matchingTypeSetters.isEmpty()) { throw new IllegalStateException(MessageFormat.format("No database type setter is defined for type \"{0}\"", databaseType)); } if (matchingTypeSetters.size() > 1) { throw new IllegalStateException(MessageFormat.format("More than one database type setters are defined for type \"{0}\"", databaseType)); } return matchingTypeSetters.get(0); } DatabaseTypeSetterFactory();  DatabaseTypeSetterFactory(List<DatabaseTypeSetter> registeredTypeSetters); DatabaseTypeSetter get(String databaseType); }
DatabaseTypeSetterFactory { public DatabaseTypeSetter get(String databaseType) { List<DatabaseTypeSetter> matchingTypeSetters = registeredTypeSetters.stream() .filter(typeSetter -> containsIgnoreCase(databaseType, typeSetter)) .collect(Collectors.toList()); if (matchingTypeSetters.isEmpty()) { throw new IllegalStateException(MessageFormat.format("No database type setter is defined for type \"{0}\"", databaseType)); } if (matchingTypeSetters.size() > 1) { throw new IllegalStateException(MessageFormat.format("More than one database type setters are defined for type \"{0}\"", databaseType)); } return matchingTypeSetters.get(0); } DatabaseTypeSetterFactory();  DatabaseTypeSetterFactory(List<DatabaseTypeSetter> registeredTypeSetters); DatabaseTypeSetter get(String databaseType);  }