nl.vpro.domain.MutableEmbargo Maven / Gradle / Ivy
package nl.vpro.domain;
import java.time.Instant;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import com.google.common.collect.Range;
/**
* As {@link Embargo} but, also includes setters
*
* @author Michiel Meeuwissen
* @since 5.1
*/
public interface MutableEmbargo> extends Embargo {
@NonNull
T setPublishStartInstant(@Nullable Instant publishStart);
@NonNull
T setPublishStopInstant(@Nullable Instant publishStop);
@SuppressWarnings("unchecked")
default T set(Range range) {
if (range.hasLowerBound()) {
setPublishStartInstant(range.lowerEndpoint());
} else {
setPublishStartInstant(null);
}
if (range.hasUpperBound()) {
setPublishStopInstant(range.upperEndpoint());
} else {
setPublishStopInstant(null);
}
return (T) this;
}
}