package com.jdbernard.timeanalyzer

import org.joda.time.Interval
import org.joda.time.ReadableInstant
import org.joda.time.ReadableInterval

public class TimeIntervalCategoryFilter implements CategoryFilter {

    ReadableInterval interval

    public TimeIntervalCategoryFilter(ReadableInterval interval) {
        this.interval = interval
    }

    public TimeIntervalCategoryFilter(ReadableInstant start, ReadableInstant end) {
        this.interval = new Interval(start, end)
    }

    public boolean matchesEvent(Event event) {
        return interval.contains(event.start)
    }
}
