001// Generated by delombok at Sun Jun 30 16:31:41 CEST 2019
002package com.credibledoc.substitution.doc.module.substitution.empty;
003
004import com.credibledoc.combiner.log.buffered.LogBufferedReader;
005import com.credibledoc.combiner.node.log.NodeLogService;
006import com.credibledoc.combiner.tactic.Tactic;
007import com.credibledoc.combiner.tactic.TacticService;
008import com.credibledoc.enricher.printable.Printable;
009import com.credibledoc.enricher.transformer.Transformer;
010import org.apache.commons.lang3.StringEscapeUtils;
011import org.springframework.stereotype.Component;
012import javax.inject.Inject;
013import java.util.List;
014
015/**
016 * Escapes the multiLine obtained in the
017 * {@link Transformer#transform(Printable, List, LogBufferedReader)} method
018 * by applying the
019 * {@link StringEscapeUtils#escapeHtml4(String)} method.
020 * 
021 * @author Kyrylo Semenko
022 */
023@Component
024public class EmptyHtmlTransformer implements Transformer {
025    @Override
026    public String transform(Printable printable, List<String> multiLine, LogBufferedReader logBufferedReader) {
027        String line = multiLine.get(0);
028        if (printable.getCacheLines().size() < EmptyTransformer.MIN_LINES_COUNT_FOR_DECISION) {
029            printable.getCacheLines().add(line);
030        }
031        String joined = String.join(System.lineSeparator(), multiLine);
032        String nodeName = NodeLogService.getInstance().findNodeName(logBufferedReader);
033        Tactic tactic = TacticService.getInstance().findTactic(logBufferedReader);
034        return StringEscapeUtils.escapeHtml4(nodeName + " " + tactic.getShortName() + " " + joined);
035    }
036
037    @Inject
038    @java.lang.SuppressWarnings("all")
039    public EmptyHtmlTransformer() {
040    }
041}