Class ConversionUtils

java.lang.Object
com.broadleafcommerce.common.dataimport.util.ConversionUtils

public final class ConversionUtils extends Object
Helper class for converting BatchRecord to target types.
Author:
Samarth Dhruva (samarthd)
  • Method Details

    • convert

      public static <T> ConversionUtils.ConversionResponse<T> convert(BatchRecord toConvert, org.springframework.core.convert.converter.Converter<BatchRecord,T> converter)
      Convert the given BatchRecord using the given converter. 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 convert
      converter - 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 a BatchCompletionRecord for the given failedToConvert batch record, and then creates BatchCompletionRecords 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 converted
      failedConversion - the response describing the errors with the conversion
      destination - the list to which the completion records should be added