All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.vpro.domain.WrappedEmbargo Maven / Gradle / Ivy

Go to download

Several domains like 'media', pages' and 'subtitles' in the POMS system share some common properties which are collected here

There is a newer version: 8.3.1
Show newest version
package nl.vpro.domain;

import java.time.Instant;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * Implementation of {@link MutableEmbargo} which wraps a {@link Supplier} and {@link Consumer} for the start and stop instant.
 * @since 7.10
 */
public class WrappedEmbargo implements MutableEmbargo {

    private final Supplier start;
    private final Consumer startSetter;
    private final Supplier stop;
    private final Consumer stopSetter;

    public WrappedEmbargo(Supplier start, Consumer startSetter, Supplier stop, Consumer stopSetter) {
        this.start = start;
        this.startSetter = startSetter;
        this.stop = stop;
        this.stopSetter = stopSetter;
    }

    @Override
    public Instant getPublishStartInstant() {
        return start.get();
    }

    @Override
    public Instant getPublishStopInstant() {
        return stop.get();
    }

    @Override
    public @NonNull WrappedEmbargo setPublishStartInstant(@Nullable Instant publishStart) {
        startSetter.accept(publishStart);
        return this;
    }

    @Override
    public @NonNull WrappedEmbargo setPublishStopInstant(@Nullable Instant publishStop) {
        stopSetter.accept(publishStop);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy