/** * Returns a converter that can convert an IntermediateRepresentation from the given {@code sourceType} to the * given {@code targetType} using a chain formed with given {@code candidates}. The returned converter * uses some (or all) of the given {@code candidates} as delegates. * * @param sourceType The source type of the converter * @param targetType The target type of the converter * @param candidates The candidates to form a chain with * @param <S> The source type of the converter * @param <T> The target type of the converter * @return A converter for the given source and target types * * @throws CannotConvertBetweenTypesException * if no converter can be created using given 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()); }
/** * Returns a converter that can convert an IntermediateRepresentation from the given {@code sourceType} to the * given {@code targetType} using a chain formed with given {@code candidates}. The returned converter * uses some (or all) of the given {@code candidates} as delegates. * * @param sourceType The source type of the converter * @param targetType The target type of the converter * @param candidates The candidates to form a chain with * @param <S> The source type of the converter * @param <T> The target type of the converter * @return A converter for the given source and target types * * @throws CannotConvertBetweenTypesException * if no converter can be created using given 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()); }
/** * Returns a converter that can convert an IntermediateRepresentation from the given {@code sourceType} to the * given {@code targetType} using a chain formed with given {@code candidates}. The returned converter * uses some (or all) of the given {@code candidates} as delegates. * * @param sourceType The source type of the converter * @param targetType The target type of the converter * @param candidates The candidates to form a chain with * @param <S> The source type of the converter * @param <T> The target type of the converter * @return A converter for the given source and target types * * @throws CannotConvertBetweenTypesException * if no converter can be created using given 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()); }