@Test public void testFindConverter_overrideDefault() { LinkkiConverterFactory linkkiConverterFactory = new LinkkiConverterFactory( () -> Sequence.of(new MyStringToDateConverter())); assertThat(linkkiConverterFactory.findConverter(String.class, Date.class), is(instanceOf(MyStringToDateConverter.class))); }
@Override @CheckForNull protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( @CheckForNull Class<PRESENTATION> presentationType, @CheckForNull Class<MODEL> modelType) { @SuppressWarnings("unchecked") @CheckForNull Converter<PRESENTATION, MODEL> converter = converterFinder.get().stream() .filter(Converter.class::isInstance) .map(Converter.class::cast) .filter(c -> c.getPresentationType().isAssignableFrom(presentationType) && c.getModelType().isAssignableFrom(modelType)) .findFirst() .orElseGet(() -> super.findConverter(presentationType, modelType)); return converter; }
LinkkiConverterFactory extends DefaultConverterFactory { @Override @CheckForNull protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( @CheckForNull Class<PRESENTATION> presentationType, @CheckForNull Class<MODEL> modelType) { @SuppressWarnings("unchecked") @CheckForNull Converter<PRESENTATION, MODEL> converter = converterFinder.get().stream() .filter(Converter.class::isInstance) .map(Converter.class::cast) .filter(c -> c.getPresentationType().isAssignableFrom(presentationType) && c.getModelType().isAssignableFrom(modelType)) .findFirst() .orElseGet(() -> super.findConverter(presentationType, modelType)); return converter; } }
LinkkiConverterFactory extends DefaultConverterFactory { @Override @CheckForNull protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( @CheckForNull Class<PRESENTATION> presentationType, @CheckForNull Class<MODEL> modelType) { @SuppressWarnings("unchecked") @CheckForNull Converter<PRESENTATION, MODEL> converter = converterFinder.get().stream() .filter(Converter.class::isInstance) .map(Converter.class::cast) .filter(c -> c.getPresentationType().isAssignableFrom(presentationType) && c.getModelType().isAssignableFrom(modelType)) .findFirst() .orElseGet(() -> super.findConverter(presentationType, modelType)); return converter; } LinkkiConverterFactory();  LinkkiConverterFactory(Supplier<Sequence<Converter<?, ?>>> converterFinder); }
LinkkiConverterFactory extends DefaultConverterFactory { @Override @CheckForNull protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( @CheckForNull Class<PRESENTATION> presentationType, @CheckForNull Class<MODEL> modelType) { @SuppressWarnings("unchecked") @CheckForNull Converter<PRESENTATION, MODEL> converter = converterFinder.get().stream() .filter(Converter.class::isInstance) .map(Converter.class::cast) .filter(c -> c.getPresentationType().isAssignableFrom(presentationType) && c.getModelType().isAssignableFrom(modelType)) .findFirst() .orElseGet(() -> super.findConverter(presentationType, modelType)); return converter; } LinkkiConverterFactory();  LinkkiConverterFactory(Supplier<Sequence<Converter<?, ?>>> converterFinder);  }
LinkkiConverterFactory extends DefaultConverterFactory { @Override @CheckForNull protected <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> findConverter( @CheckForNull Class<PRESENTATION> presentationType, @CheckForNull Class<MODEL> modelType) { @SuppressWarnings("unchecked") @CheckForNull Converter<PRESENTATION, MODEL> converter = converterFinder.get().stream() .filter(Converter.class::isInstance) .map(Converter.class::cast) .filter(c -> c.getPresentationType().isAssignableFrom(presentationType) && c.getModelType().isAssignableFrom(modelType)) .findFirst() .orElseGet(() -> super.findConverter(presentationType, modelType)); return converter; } LinkkiConverterFactory();  LinkkiConverterFactory(Supplier<Sequence<Converter<?, ?>>> converterFinder);  static final Sequence<Converter<?, ?>> DEFAULT_JAVA_8_DATE_CONVERTERS; }