com.acrolinx.sidebar.pojo.document.CheckResultFromJSON Maven / Gradle / Ivy
/* Copyright (c) 2018 Acrolinx GmbH */
package com.acrolinx.sidebar.pojo.document;
import com.acrolinx.sidebar.pojo.SidebarError;
import java.util.LinkedHashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CheckResultFromJSON {
private static final Logger logger = LoggerFactory.getLogger(CheckResultFromJSON.class);
private CheckedDocumentPartFromJSON checkedPart;
private SidebarError sidebarError;
private CheckInformationKeyValuePairFromJSON[] embedCheckInformation;
private String inputFormat;
CheckResultFromJSON() {}
public CheckResult getAsCheckResult() {
if (this.sidebarError != null) {
logger.warn("Message: {}, Code: {}", sidebarError.getMessage(), sidebarError.getErrorCode());
return null;
}
return new CheckResult(checkedPart.getAsCheckResult(), getEmbedCheckInformation(), inputFormat);
}
private Map getEmbedCheckInformation() {
final Map map = new LinkedHashMap<>();
if (embedCheckInformation == null) {
return null;
}
for (final CheckInformationKeyValuePairFromJSON checkInformationKeyValuePairFromJSON :
embedCheckInformation) {
map.put(
checkInformationKeyValuePairFromJSON.getKey(),
checkInformationKeyValuePairFromJSON.getValue());
}
return map;
}
}