Class ConcatenationConverter<SourceType,IntermediateType,TargetType>
java.lang.Object
com.saperion.common.lang.conversion.ConcatenationConverter<SourceType,IntermediateType,TargetType>
- All Implemented Interfaces:
Converter<SourceType,TargetType>
public class ConcatenationConverter<SourceType,IntermediateType,TargetType>
extends Object
implements Converter<SourceType,TargetType>
Concatenates two
Converters to obtain another
Converter.
For a given Converter<T1, T2> A and a given Converter<T2, T3> A the ConcatenationConverter(A, B)
will convert given instances of T1 to T3 by first converting to T2 with A and then to T3 with B.- Author:
- jschwarz
-
Constructor Summary
ConstructorsConstructorDescriptionConcatenationConverter(Converter<SourceType, IntermediateType> firstConverter, Converter<IntermediateType, TargetType> secondConverter) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T1,T2, T3> Converter<T1, T3> concatenate(Converter<T1, T2> first, Converter<T2, T3> second) Convenience factory method omitting the explicit generic parameters.static <T1,T2, T3, T4>
Converter<T1,T4> concatenate(Converter<T1, T2> first, Converter<T2, T3> second, Converter<T3, T4> third) Convenience factory method omitting the explicit generic parameters.static <T1,T2, T3, T4, T5>
Converter<T1,T5> concatenate(Converter<T1, T2> first, Converter<T2, T3> second, Converter<T3, T4> third, Converter<T4, T5> fourth) Convenience factory method omitting the explicit generic parameters.convert(SourceType sourceType) Converts the specified object and returns the conversion result.
-
Constructor Details
-
ConcatenationConverter
public ConcatenationConverter(Converter<SourceType, IntermediateType> firstConverter, Converter<IntermediateType, TargetType> secondConverter)
-
-
Method Details
-
convert
Description copied from interface:ConverterConverts the specified object and returns the conversion result. Implementations have to acceptnull-values without throwing exceptions.- Specified by:
convertin interfaceConverter<SourceType,IntermediateType> - Parameters:
sourceType- object to convert- Returns:
- the converted object
-
concatenate
public static <T1,T2, Converter<T1,T3> T3> concatenate(Converter<T1, T2> first, Converter<T2, T3> second) Convenience factory method omitting the explicit generic parameters.- Type Parameters:
T1- the input typeT2- the type the first converter converts to and the second converts fromT3- the output type- Parameters:
first- The first converter to concatenatesecond- The second converter to concatenate- Returns:
- A ConcatenationConverter for the given converters.
-
concatenate
public static <T1,T2, Converter<T1,T3, T4> T4> concatenate(Converter<T1, T2> first, Converter<T2, T3> second, Converter<T3, T4> third) Convenience factory method omitting the explicit generic parameters.- Type Parameters:
T1- the input typeT2- an intermediate typeT3- an intermediate typeT4- the output type- Parameters:
first- The first converter to concatenatesecond- The second converter to concatenatethird- The third converter to concatenate- Returns:
- A ConcatenationConverter for the given converters.
-
concatenate
public static <T1,T2, Converter<T1,T3, T4, T5> T5> concatenate(Converter<T1, T2> first, Converter<T2, T3> second, Converter<T3, T4> third, Converter<T4, T5> fourth) Convenience factory method omitting the explicit generic parameters.- Type Parameters:
T1- the input typeT2- an intermediate typeT3- an intermediate typeT4- an intermediate typeT5- the output type- Parameters:
first- The first converter to concatenatesecond- The second converter to concatenatethird- The third converter to concatenatefourth- The fourth converter to concatenate- Returns:
- A ConcatenationConverter for the given converters.
-