ConverterFactory { @SuppressWarnings("unchecked") public static <T> Converter<String, T> createConverterFor(Class<T> clazz, AttributeModel attributeModel, boolean grouping) { if (NumberUtils.isInteger(attributeModel.getType())) { return (Converter<String, T>) createIntegerConverter(grouping, attributeModel.isPercentage()); } else if (NumberUtils.isLong(attributeModel.getType())) { return (Converter<String, T>) createLongConverter(grouping, attributeModel.isPercentage()); } else if (NumberUtils.isDouble(attributeModel.getType())) { return (Converter<String, T>) createDoubleConverter(attributeModel.isCurrency(), grouping, attributeModel.isPercentage(), attributeModel.getPrecision(), SystemPropertyUtils.getDefaultCurrencySymbol()); } else if (clazz.equals(BigDecimal.class)) { return (Converter<String, T>) createBigDecimalConverter(attributeModel.isCurrency(), attributeModel.isPercentage(), grouping, attributeModel.getPrecision(), SystemPropertyUtils.getDefaultCurrencySymbol()); } return null; } private  ConverterFactory(); static BigDecimalConverter createBigDecimalConverter(boolean currency, boolean percentage,
			boolean useGrouping, int precision, String currencySymbol); @SuppressWarnings("unchecked") static Converter<String, T> createConverterFor(Class<T> clazz, AttributeModel attributeModel,
			boolean grouping); static StringToIntegerConverter createIntegerConverter(boolean useGrouping, boolean percentage); static StringToLongConverter createLongConverter(boolean useGrouping, boolean percentage); static StringToDoubleConverter createDoubleConverter(boolean currency, boolean percentage,
			boolean useGrouping, int precision, String currencySymbol); static ZonedDateTimeToLocalDateTimeConverter createZonedDateTimeConverter(ZoneId zoneId);  }
@Test public void testGetConverterFor() { Converter<?, ?> cv = ConverterFactory.createConverterFor(Integer.class, em.getAttributeModel("someInt"), true); assertTrue(cv instanceof GroupingStringToIntegerConverter); cv = ConverterFactory.createConverterFor(Long.class, em.getAttributeModel("age"), true); assertTrue(cv instanceof GroupingStringToLongConverter); cv = ConverterFactory.createConverterFor(BigDecimal.class, em.getAttributeModel("rate"), true); assertTrue(cv instanceof BigDecimalConverter); }