package com.capgemini.reports.periodicity;

import com.capgemini.reports.database.javabean.enumeration.SchedulingEnum;
import com.capgemini.reports.database.manager.MngSchedulingCriteriaVal.SchedulingCriteriaValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/** Represents an event that occurs every week, on a specific week day. */
@AllArgsConstructor
@Getter
public class WeeklyPeriod implements SchedulingPeriod {

    private final int dayInWeek;

    @Override
    public SchedulingEnum getPeriodicity() {
        return SchedulingEnum.WEEKLY;
    }

    @Override
    public <T> T accept(final PeriodVisitor<T> visitor) {
        return visitor.visit(this);
    }

    @Override
    public List<SchedulingCriteriaValue> asCriteriaValues() {
        List<SchedulingCriteriaValue> list = new ArrayList<>(2);
        list.add(new SchedulingCriteriaValue(SchedulingEnum.PERIOD, SchedulingEnum.WEEKLY.getCriteriaName()));
        list.add(new SchedulingCriteriaValue(SchedulingEnum.WEEKLY, String.valueOf(dayInWeek)));
        return list;
    }
}
