package cz.senslog.connector.fetch.alapans;

import cz.senslog.connector.model.api.ProxySessionModel;

import java.time.LocalDate;

public class AlapansSession extends ProxySessionModel {

    private int nextOffset;

    private Boolean hasMore;

    private LocalDate fromDate, toDate;

    public static AlapansSession emptySession() {
        return new AlapansSession(false);
    }

    AlapansSession(boolean isActive) {
        super(isActive);
        this.nextOffset = 0;
        this.hasMore = null;
    }

    public LocalDate getFromDate() {
        return fromDate;
    }

    public void setFromDate(LocalDate fromDate) {
        this.fromDate = fromDate;
    }

    public LocalDate getToDate() {
        return toDate;
    }

    public void setToDate(LocalDate toDate) {
        this.toDate = toDate;
    }

    public int getNextOffset() {
        return nextOffset;
    }

    public void setNextOffset(int nextOffset) {
        this.nextOffset = nextOffset;
    }

    public Boolean hasNext() {
        return hasMore;
    }

    public boolean isNotInitialized() {
        return hasMore == null;
    }

    public boolean isEndOfIntervalIteration() {
        return nextOffset == 0 && hasMore != null && !hasMore && toDate != null && fromDate != null;
    }

    public void setHasMore(Boolean hasMore) {
        this.hasMore = hasMore;
    }
}
