package com.easyagents.rag.ingestion.model;

import com.easyagents.rag.core.RagDefaults;
import com.easyagents.rag.core.RagStrategyCodes;

import java.io.Serializable;

public class StrategyConfig implements Serializable {

    private String strategyCode = RagStrategyCodes.AUTO;
    private Integer chunkSize = RagDefaults.CHUNK_SIZE;
    private Integer overlapSize = RagDefaults.OVERLAP_SIZE;
    private String regex;
    /**
     * Whether a custom-regex match is retained at the beginning of the next chunk.
     */
    private Boolean retainRegexMatch;
    private Integer rowsPerChunk = RagDefaults.ROWS_PER_CHUNK;
    private Integer mdSplitterLevel = RagDefaults.MD_SPLITTER_LEVEL;

    public static StrategyConfig defaults() {
        return new StrategyConfig();
    }

    public StrategyConfig copy() {
        StrategyConfig copy = new StrategyConfig();
        copy.setStrategyCode(this.strategyCode);
        copy.setChunkSize(this.chunkSize);
        copy.setOverlapSize(this.overlapSize);
        copy.setRegex(this.regex);
        copy.setRetainRegexMatch(this.retainRegexMatch);
        copy.setRowsPerChunk(this.rowsPerChunk);
        copy.setMdSplitterLevel(this.mdSplitterLevel);
        return copy;
    }

    public String getStrategyCode() {
        return strategyCode;
    }

    public void setStrategyCode(String strategyCode) {
        this.strategyCode = strategyCode;
    }

    public Integer getChunkSize() {
        return chunkSize;
    }

    public void setChunkSize(Integer chunkSize) {
        this.chunkSize = chunkSize;
    }

    public Integer getOverlapSize() {
        return overlapSize;
    }

    public void setOverlapSize(Integer overlapSize) {
        this.overlapSize = overlapSize;
    }

    public String getRegex() {
        return regex;
    }

    public void setRegex(String regex) {
        this.regex = regex;
    }

    /**
     * Returns whether custom-regex matches are retained in the next chunk.
     *
     * @return {@code true} to retain each match at the beginning of the next chunk;
     * otherwise {@code false} or {@code null}
     */
    public Boolean getRetainRegexMatch() {
        return retainRegexMatch;
    }

    /**
     * Sets whether custom-regex matches are retained in the next chunk.
     *
     * @param retainRegexMatch {@code true} to retain each match; {@code false} to discard it
     */
    public void setRetainRegexMatch(Boolean retainRegexMatch) {
        this.retainRegexMatch = retainRegexMatch;
    }

    public Integer getRowsPerChunk() {
        return rowsPerChunk;
    }

    public void setRowsPerChunk(Integer rowsPerChunk) {
        this.rowsPerChunk = rowsPerChunk;
    }

    public Integer getMdSplitterLevel() {
        return mdSplitterLevel;
    }

    public void setMdSplitterLevel(Integer mdSplitterLevel) {
        this.mdSplitterLevel = mdSplitterLevel;
    }
}
