@Test void testInexistentRoute() { target = InputStream.class; source = new StringReader("hello"); assertThrows(CannotConvertBetweenTypesException.class, () -> ChainedConverter.calculateChain(Reader.class, target, candidates)); }
public static <S, T> ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?, ?>> candidates) { Route route = calculateRoute(sourceType, targetType, candidates); if (route == null) { throw new CannotConvertBetweenTypesException(format("Cannot build a converter to convert from %s to %s", sourceType.getName(), targetType.getName())); } return new ChainedConverter<>(route.asList()); }
ChainedConverter implements ContentTypeConverter<S, T> { public static <S, T> ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?, ?>> candidates) { Route route = calculateRoute(sourceType, targetType, candidates); if (route == null) { throw new CannotConvertBetweenTypesException(format("Cannot build a converter to convert from %s to %s", sourceType.getName(), targetType.getName())); } return new ChainedConverter<>(route.asList()); } }
ChainedConverter implements ContentTypeConverter<S, T> { public static <S, T> ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?, ?>> candidates) { Route route = calculateRoute(sourceType, targetType, candidates); if (route == null) { throw new CannotConvertBetweenTypesException(format("Cannot build a converter to convert from %s to %s", sourceType.getName(), targetType.getName())); } return new ChainedConverter<>(route.asList()); } @SuppressWarnings({"unchecked", "ConstantConditions"})  ChainedConverter(List<ContentTypeConverter<?,?>> delegates); }
ChainedConverter implements ContentTypeConverter<S, T> { public static <S, T> ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?, ?>> candidates) { Route route = calculateRoute(sourceType, targetType, candidates); if (route == null) { throw new CannotConvertBetweenTypesException(format("Cannot build a converter to convert from %s to %s", sourceType.getName(), targetType.getName())); } return new ChainedConverter<>(route.asList()); } @SuppressWarnings({"unchecked", "ConstantConditions"})  ChainedConverter(List<ContentTypeConverter<?,?>> delegates); static ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType,
                                                               Collection<ContentTypeConverter<?, ?>> candidates); static boolean canConvert(Class<S> sourceContentType, Class<T> targetContentType,
                                            List<ContentTypeConverter<?, ?>> converters); @SuppressWarnings({"unchecked"}) @Override T convert(S original); @Override Class<S> expectedSourceType(); @Override Class<T> targetType(); }
ChainedConverter implements ContentTypeConverter<S, T> { public static <S, T> ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?, ?>> candidates) { Route route = calculateRoute(sourceType, targetType, candidates); if (route == null) { throw new CannotConvertBetweenTypesException(format("Cannot build a converter to convert from %s to %s", sourceType.getName(), targetType.getName())); } return new ChainedConverter<>(route.asList()); } @SuppressWarnings({"unchecked", "ConstantConditions"})  ChainedConverter(List<ContentTypeConverter<?,?>> delegates); static ChainedConverter<S, T> calculateChain(Class<S> sourceType, Class<T> targetType,
                                                               Collection<ContentTypeConverter<?, ?>> candidates); static boolean canConvert(Class<S> sourceContentType, Class<T> targetContentType,
                                            List<ContentTypeConverter<?, ?>> converters); @SuppressWarnings({"unchecked"}) @Override T convert(S original); @Override Class<S> expectedSourceType(); @Override Class<T> targetType();  }