package com.capgemini.reports.periodicity;

import com.capgemini.reports.database.javabean.enumeration.SchedulingEnum;
import com.capgemini.reports.database.manager.MngSchedulingCriteriaVal.SchedulingCriteriaValue;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

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

/**
 * Represents a daily execution.
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DailyPeriod implements SchedulingPeriod {

    private static final DailyPeriod instance = new DailyPeriod();

    /**
     * Get an instance. All instances are the same as this one (singleton).
     * 
     * @return an instance
     */
    public static DailyPeriod getInstance() {
        return instance;
    }

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

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

    @Override
    public List<SchedulingCriteriaValue> asCriteriaValues() {
        List<SchedulingCriteriaValue> list = new ArrayList<>(1);
        list.add(new SchedulingCriteriaValue(SchedulingEnum.PERIOD, SchedulingEnum.DAILY.getCriteriaName()));
        return list;
    }
}
