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

com.github.rahulsom.grooves.queries.VersionedQuery Maven / Gradle / Ivy

The newest version!
package com.github.rahulsom.grooves.queries;

import com.github.rahulsom.grooves.api.events.BaseEvent;
import com.github.rahulsom.grooves.api.snapshots.VersionedSnapshot;
import org.jetbrains.annotations.NotNull;
import org.reactivestreams.Publisher;

/**
 * A query that produces a {@link VersionedSnapshot}.
 *
 * @param   The aggregate over which the query executes
 * @param     The type of the EventT's id field
 * @param       The type of the event
 * @param  The type of the SnapshotT's id field
 * @param    The type of the snapshot
 * @author Rahul Somasunderam
 */
public interface VersionedQuery<
        AggregateT,
        EventIdT,
        EventT extends BaseEvent,
        SnapshotIdT,
        SnapshotT extends VersionedSnapshot> {
    /**
     * Computes a snapshot for specified version of an aggregate.
     *
     * @param aggregate The aggregate
     * @param version   The version number, starting at 1
     * @return A Publisher that returns at most one Snapshot
     */
    @NotNull Publisher computeSnapshot(
            @NotNull AggregateT aggregate, long version);

    /**
     * Computes a snapshot for specified version of an aggregate.
     *
     * @param aggregate The aggregate
     * @param version   The version number, starting at 1
     * @param redirect  If there has been a deprecation, redirect to the current aggregate's
     *                  snapshot. Defaults to true.
     * @return A Publisher that returns at most one Snapshot
     */
    @NotNull Publisher computeSnapshot(
            @NotNull AggregateT aggregate, long version, boolean redirect);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy