Class ExcelValidationResultUtil
- java.lang.Object
-
- com.hybris.backoffice.excel.validators.util.ExcelValidationResultUtil
-
public class ExcelValidationResultUtil extends java.lang.ObjectUtil class responsible for merging validation messages. When list ofExcelValidationResultcontains results which belong to the same rows, then suchExcelValidationResultare merged - all messages are put to oneExcelValidationResultand common validation header is created. This class also adds appropriate headers and metadata to excel validation result if needed.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidinsertHeaderIfNeeded(ExcelValidationResult singleResult, int rowIndex, java.lang.String typeCode, java.lang.String attributeName)Creates validation header if givenExcelValidationResultdoes not have it.static java.util.Collection<ValidationMessage>mapExcelResultsToValidationMessages(java.util.Collection<ExcelValidationResult> results)Allows to retrieve allValidationMessages from givenExcelValidationResults and returns the flat structure.static ExcelValidationResultmergeExcelValidationResults(java.util.Collection<ExcelValidationResult> results)Allows to merge the list of errors fromExcelValidationResultto singleExcelValidationResult.static java.util.List<ExcelValidationResult>mergeValidationResults(java.util.List<ExcelValidationResult> resultsToMerge)FindsExcelValidationResultwhich belong to the same row and creates newExcelValidationResultwhich consists of mergedValidationMessageand common header.
-
-
-
Method Detail
-
insertHeaderIfNeeded
public static void insertHeaderIfNeeded(ExcelValidationResult singleResult, int rowIndex, java.lang.String typeCode, java.lang.String attributeName)
Creates validation header if givenExcelValidationResultdoes not have it. Moreover this methods populates metadata information about given validation result, for example: rowIndex, typeCode and attribute name.- Parameters:
singleResult-rowIndex-typeCode-attributeName-
-
mergeValidationResults
public static java.util.List<ExcelValidationResult> mergeValidationResults(java.util.List<ExcelValidationResult> resultsToMerge)
FindsExcelValidationResultwhich belong to the same row and creates newExcelValidationResultwhich consists of mergedValidationMessageand common header. This method returns new merged list ofExcelValidationResult.- Parameters:
resultsToMerge-- Returns:
- returns new merged list of
ExcelValidationResult
-
mergeExcelValidationResults
public static ExcelValidationResult mergeExcelValidationResults(@Nonnull java.util.Collection<ExcelValidationResult> results)
Allows to merge the list of errors fromExcelValidationResultto singleExcelValidationResult.- Parameters:
results- to merge- Returns:
- merged result
-
mapExcelResultsToValidationMessages
public static java.util.Collection<ValidationMessage> mapExcelResultsToValidationMessages(@Nonnull java.util.Collection<ExcelValidationResult> results)
Allows to retrieve allValidationMessages from givenExcelValidationResults and returns the flat structure.- Parameters:
results- to map- Returns:
- collection of
ValidationMessage
-
-