001package com.credibledoc.substitution.doc.module.substitution.empty; 002 003import com.credibledoc.combiner.log.buffered.LogBufferedReader; 004import com.credibledoc.enricher.printable.Printable; 005import com.credibledoc.enricher.transformer.Transformer; 006import org.springframework.stereotype.Component; 007 008import java.util.List; 009 010/** 011 * Copy lines as is, without transformation. 012 * @author Kyrylo Semenko 013 */ 014@Component 015public class EmptyTransformer implements Transformer { 016 017 /** 018 * We need to know, if the current document is empty or contains some rows. 019 * We need it for decision, if wee should create a new document, or we 020 * should remain the current document for filling. 021 */ 022 static final int MIN_LINES_COUNT_FOR_DECISION = 2; 023 024 @Override 025 public String transform(Printable printable, List<String> multiLine, LogBufferedReader logBufferedReader) { 026 if (printable.getCacheLines().size() < MIN_LINES_COUNT_FOR_DECISION) { 027 printable.getCacheLines().add(multiLine.get(0)); 028 } 029 return String.join(System.lineSeparator(), multiLine); 030 } 031 032}