Class ConversionUtils
java.lang.Object
com.broadleafcommerce.common.dataimport.util.ConversionUtils
Helper class for converting
BatchRecord
to target types.- Author:
- Samarth Dhruva (samarthd)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A response indicating the results of attempting to convert aBatchRecord
to a target type. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
addFailedConversionCompletions
(BatchRecord failedToConvert, ConversionUtils.ConversionResponse<T> failedConversion, List<BatchCompletionRecord> destination) Creates aBatchCompletionRecord
for the givenfailedToConvert
batch record, and then createsBatchCompletionRecords
for all of its nested dependents.static <T> ConversionUtils.ConversionResponse<T>
convert
(BatchRecord toConvert, org.springframework.core.convert.converter.Converter<BatchRecord, T> converter) Convert the givenBatchRecord
using the givenconverter
.
-
Method Details
-
convert
public static <T> ConversionUtils.ConversionResponse<T> convert(BatchRecord toConvert, org.springframework.core.convert.converter.Converter<BatchRecord, T> converter) Convert the givenBatchRecord
using the givenconverter
. If an error is thrown or the result of the conversion is null, an error response will be produced and the error will be logged. If no error is thrown and the result is non-null, a response containing the converted value will be produced.- Type Parameters:
T
- the type that the converter can output- Parameters:
toConvert
- the batch record to convertconverter
- the converter capable of performing the required conversion- Returns:
- a response containing the results of performing the conversion
-
addFailedConversionCompletions
public static <T> void addFailedConversionCompletions(BatchRecord failedToConvert, ConversionUtils.ConversionResponse<T> failedConversion, List<BatchCompletionRecord> destination) Creates aBatchCompletionRecord
for the givenfailedToConvert
batch record, and then createsBatchCompletionRecords
for all of its nested dependents.All of these completion records are added to the
destination
.- Parameters:
failedToConvert
- the batch record that could not be convertedfailedConversion
- the response describing the errors with the conversiondestination
- the list to which the completion records should be added
-