/** * Creates a new instance that uses the given {@code delegates} to form a chain of converters. Note that the * {@code delegates} must for a Continuous chain, meaning that each item must produce an * IntermediateRepresentation of a type that can be consumed by the next delegate. * <p/> * To automatically calculate a route between converters, see {@link #calculateChain(Class source, Class target, * java.util.Collection candidates) calculateChain(source, target, candidates)} * * @param delegates the chain of delegates to perform the conversion */ @SuppressWarnings({"unchecked", "ConstantConditions"}) public ChainedConverter(List<ContentTypeConverter<?,?>> delegates) { Assert.isTrue(delegates != null && !delegates.isEmpty(), () -> "The given delegates may not be null or empty"); Assert.isTrue(isContinuous(delegates), () -> "The given delegates must form a continuous chain"); this.delegates = new ArrayList<>(delegates); target = (Class<T>) this.delegates.get(this.delegates.size() - 1).targetType(); source = (Class<S>) delegates.get(0).expectedSourceType(); }
/** * Creates a new instance that uses the given {@code delegates} to form a chain of converters. Note that the * {@code delegates} must for a Continuous chain, meaning that each item must produce an * IntermediateRepresentation of a type that can be consumed by the next delegate. * <p/> * To automatically calculate a route between converters, see {@link #calculateChain(Class source, Class target, * java.util.Collection candidates) calculateChain(source, target, candidates)} * * @param delegates the chain of delegates to perform the conversion */ @SuppressWarnings({"unchecked", "ConstantConditions"}) public ChainedConverter(List<ContentTypeConverter<?,?>> delegates) { Assert.isTrue(delegates != null && !delegates.isEmpty(), () -> "The given delegates may not be null or empty"); Assert.isTrue(isContinuous(delegates), () -> "The given delegates must form a continuous chain"); this.delegates = new ArrayList<>(delegates); target = (Class<T>) this.delegates.get(this.delegates.size() - 1).targetType(); source = (Class<S>) delegates.get(0).expectedSourceType(); }
/** * Creates a new instance that uses the given {@code delegates} to form a chain of converters. Note that the * {@code delegates} must for a Continuous chain, meaning that each item must produce an * IntermediateRepresentation of a type that can be consumed by the next delegate. * <p/> * To automatically calculate a route between converters, see {@link #calculateChain(Class source, Class target, * java.util.Collection candidates) calculateChain(source, target, candidates)} * * @param delegates the chain of delegates to perform the conversion */ @SuppressWarnings({"unchecked", "ConstantConditions"}) public ChainedConverter(List<ContentTypeConverter<?,?>> delegates) { Assert.isTrue(delegates != null && !delegates.isEmpty(), () -> "The given delegates may not be null or empty"); Assert.isTrue(isContinuous(delegates), () -> "The given delegates must form a continuous chain"); this.delegates = new ArrayList<>(delegates); target = (Class<T>) this.delegates.get(this.delegates.size() - 1).targetType(); source = (Class<S>) delegates.get(0).expectedSourceType(); }