package cz.senslog.connector.tools.util;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;

public final class TimeRange<T extends Temporal> {

    private final T from;

    private final T to;

    public static <T extends Instant> TimeRange<T> of(T from, T to) {
        return new TimeRange<T>(from, to);
    }

    private TimeRange(T from, T to) {
        this.from = from;
        this.to = to;
    }

    public T getFrom() {
        return from;
    }

    public T getTo() {
        return to;
    }

    public long difference(ChronoUnit chronoUnit) {
        return from.until(to, chronoUnit);
    }

//    public boolean isIncluded(T value) {
//        return from.equals(value) || (from.isBefore(value) && to.isAfter(value)) || to.equals(value);
//    }
}
