001package com.credibledoc.substitution.reporting.placeholder;
002
003import com.credibledoc.substitution.core.placeholder.Placeholder;
004import com.credibledoc.substitution.reporting.reportdocument.ReportDocument;
005
006/**
007 * The stateless service for working with relationship between {@link ReportDocument}
008 * and {@link com.credibledoc.substitution.core.placeholder.Placeholder}.
009 *
010 * @author Kyrylo Semenko
011 */
012public class PlaceholderToReportDocumentService {
013
014    /**
015     * Singleton.
016     */
017    private static final PlaceholderToReportDocumentService instance = new PlaceholderToReportDocumentService();
018
019    /**
020     * @return The {@link PlaceholderToReportDocumentService} singleton.
021     */
022    public static PlaceholderToReportDocumentService getInstance() {
023        return instance;
024    }
025
026    /**
027     * Find a value from {@link PlaceholderToReportDocumentRepository#getPlaceholderToReportDocumentMap()} by the key
028     * @param placeholder a key
029     * @return ReportDocument from the map.
030     */
031    public ReportDocument getReportDocument(Placeholder placeholder) {
032        return PlaceholderToReportDocumentRepository.getInstance()
033            .getPlaceholderToReportDocumentMap().get(placeholder);
034    }
035
036    /**
037     * Put arguments to the {@link PlaceholderToReportDocumentRepository#getPlaceholderToReportDocumentMap()} map.
038     * @param placeholder a key
039     * @param reportDocument a value
040     */
041    public void putPlaceholderToReportDocument(Placeholder placeholder, ReportDocument reportDocument) {
042        PlaceholderToReportDocumentRepository.getInstance()
043            .getPlaceholderToReportDocumentMap().put(placeholder, reportDocument);
044    }
045}