@Test public void forTypeReturnsAConverterWithOptionsMatchingTheTypeName() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { final String[] options = {"a", "b"}; final Converter encodedString = Converters.forType(StringToEncodedStringOfLimitedValuesConverter.TYPE, options); final Converter encodedArray = Converters.forType(StringArrayToEncodedArrayOfLimitedValues.TYPE, options); final Converter unEncodedString = Converters.forType(StringToUnencodedStringOfLimitedValuesConverter.TYPE, options); assertThat(encodedString, instanceOf(StringToEncodedStringOfLimitedValuesConverter.class)); assertThat(encodedArray, instanceOf(StringArrayToEncodedArrayOfLimitedValues.class)); assertThat(unEncodedString, instanceOf(StringToUnencodedStringOfLimitedValuesConverter.class)); assertThat(((HasOptions) encodedString).getOptions(), contains("a", "b")); assertThat(((HasOptions) encodedArray).getOptions(), contains("a", "b")); assertThat(((HasOptions) unEncodedString).getOptions(), contains("a", "b")); }
public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } }
Converters { public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } } }
Converters { public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } }  }
Converters { public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } }  static StringArrayToEncodedArrayOfLimitedValues stringArrayToEncodedArrayOf(String... values); static StringToEncodedStringOfLimitedValuesConverter stringToEncodedStringOf(String... values); static StringToUnencodedStringOfLimitedValuesConverter stringToUnencodedStringOf(String... values); static Converter forType(String type, String... options); }
Converters { public static Converter forType(String type, String... options) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { final Class<? extends Converter> converterClass = CONVERTER_TYPES.get(type); if (HasOptions.class.isAssignableFrom(converterClass)) { final Constructor<? extends Converter> hasOptionsConstructor = converterClass.getDeclaredConstructor(String[].class); return hasOptionsConstructor.newInstance((Object) options); } else { return converterClass.newInstance(); } }  static StringArrayToEncodedArrayOfLimitedValues stringArrayToEncodedArrayOf(String... values); static StringToEncodedStringOfLimitedValuesConverter stringToEncodedStringOf(String... values); static StringToUnencodedStringOfLimitedValuesConverter stringToUnencodedStringOf(String... values); static Converter forType(String type, String... options); static final StringToStringConverter stringToString; static final ArrayToEncodedArrayConverter arrayToEncodedArray; static final HyperlinksConverter hyperlinks; static final DatableConverter datable; static final StringToEncodedStringOfLimitedValuesConverter gender; static final PersonNamesConverter personNames; static final StringToUnencodedStringOfLimitedValuesConverter stringOfYesNoUnknown; static final DefaultLocationNameConverter defaultLocationNameConverter; static final DefaultFullPersonNameConverter defaultFullPersonNameConverter; static final AltNamesConverter altNames; }