// Path: core/src/main/java/eventsrc4j/SequenceQuery.java
// @data
// public abstract class SequenceQuery<S> {
//   public interface Cases<S, R> {
//     R Before(S s);
// 
//     R Earliest();
// 
//     R Latest();
//   }
// 
//   SequenceQuery() {
//   }
// 
// 
//   public abstract <R> R match(Cases<S, R> cases);
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// }
// 
// Path: core/src/main/java/eventsrc4j/Snapshot.java
// @data
// public abstract class Snapshot<S, V> {
// 
//   public interface Cases<S, V, R> {
// 
//     /**
//      * Events have been saved and there is a value stored.
//      *
//      * @param seq the point in the stream that this Snapshot is for.
//      * @param view the view on the stream upto to that point.
//      */
//     R Value(S seq, Instant time, V view);
// 
//     /**
//      * There is no snapshot... i.e. no events have been saved.
//      */
//     R NoSnapshot();
// 
//     /**
//      * Events have been saved and there is no value (i.e. the value has been deleted).
//      *
//      * @param seq Represents the point in the stream where the deletion occured.
//      */
//     R Deleted(S seq, Instant time);
//   }
// 
//   Snapshot() {
//   }
// 
//   public abstract <R> R match(Cases<S, V, R> cases);
// 
//   public final Option<S> seq() {
//     return getSeq(this);
//   }
// 
//   public final Option<Instant> time() {
//     return getTime(this);
//   }
// 
//   public final Option<V> view() {
//     return getView(this);
//   }
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// 
//   static final Equal<Instant> instantEqual = Equal.anyEqual();
//   static final Hash<Instant> instantHash = Hash.anyHash();
//   static final Show<Instant> instantShow = Show.anyShow();
//   static final Ord<Instant> instantOrd = Ord.comparableOrd();
// }
// 
// Path: core/src/main/java/eventsrc4j/SnapshotStoreMode.java
// @data
// public abstract class SnapshotStoreMode {
//   SnapshotStoreMode(){}
// 
//   public interface Cases<R> {
//     R Epoch();
//     R Cache();
//   }
// 
//   public abstract <R> R match(Cases<R> cases);
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// 
// }


import eventsrc4j.SequenceQuery;
import eventsrc4j.Snapshot;
import eventsrc4j.SnapshotStoreMode;
package eventsrc4j.io;


/**
 * Implementations of this interface deal with persisting snapshots for a specific key.
 *
 * @param <V> The type of the value wrapped by Snapshots that this store persists.
 */
public interface SnapshotStream<S, V> {

  /**
   * Retrieve a snapshot before the given sequence number. We typically specify a sequence number if we want to get
   * some old snapshot i.e. the latest persisted snapshot may have been generated after the point in time that we're
   * interested in.
   *
   * @param sequence What sequence we want to get the snapshot for (earliest snapshot, latest, or latest before some sequence)
   * @return The snapshot, a NoSnapshot if there was no snapshot for the given conditions.
   */
  IO<Snapshot<S, V>> get(SequenceQuery<S> sequence);

  /**
   * Save a given snapshot
   * @param snapshot The snapshot to save
   * @param mode Defines whether the given snapshot should be deemed the earliest point in the event stream (Epoch) or not (Cache)
   * @return the saved snapshot.
   */
// Path: core/src/main/java/eventsrc4j/SequenceQuery.java
// @data
// public abstract class SequenceQuery<S> {
//   public interface Cases<S, R> {
//     R Before(S s);
// 
//     R Earliest();
// 
//     R Latest();
//   }
// 
//   SequenceQuery() {
//   }
// 
// 
//   public abstract <R> R match(Cases<S, R> cases);
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// }
// 
// Path: core/src/main/java/eventsrc4j/Snapshot.java
// @data
// public abstract class Snapshot<S, V> {
// 
//   public interface Cases<S, V, R> {
// 
//     /**
//      * Events have been saved and there is a value stored.
//      *
//      * @param seq the point in the stream that this Snapshot is for.
//      * @param view the view on the stream upto to that point.
//      */
//     R Value(S seq, Instant time, V view);
// 
//     /**
//      * There is no snapshot... i.e. no events have been saved.
//      */
//     R NoSnapshot();
// 
//     /**
//      * Events have been saved and there is no value (i.e. the value has been deleted).
//      *
//      * @param seq Represents the point in the stream where the deletion occured.
//      */
//     R Deleted(S seq, Instant time);
//   }
// 
//   Snapshot() {
//   }
// 
//   public abstract <R> R match(Cases<S, V, R> cases);
// 
//   public final Option<S> seq() {
//     return getSeq(this);
//   }
// 
//   public final Option<Instant> time() {
//     return getTime(this);
//   }
// 
//   public final Option<V> view() {
//     return getView(this);
//   }
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// 
//   static final Equal<Instant> instantEqual = Equal.anyEqual();
//   static final Hash<Instant> instantHash = Hash.anyHash();
//   static final Show<Instant> instantShow = Show.anyShow();
//   static final Ord<Instant> instantOrd = Ord.comparableOrd();
// }
// 
// Path: core/src/main/java/eventsrc4j/SnapshotStoreMode.java
// @data
// public abstract class SnapshotStoreMode {
//   SnapshotStoreMode(){}
// 
//   public interface Cases<R> {
//     R Epoch();
//     R Cache();
//   }
// 
//   public abstract <R> R match(Cases<R> cases);
// 
//   @Override
//   public abstract int hashCode();
// 
//   @Override
//   public abstract boolean equals(Object obj);
// 
//   @Override
//   public abstract String toString();
// 
// }


// Path: core/src/main/java/eventsrc4j/io/SnapshotStream.java
import eventsrc4j.SequenceQuery;
import eventsrc4j.Snapshot;
import eventsrc4j.SnapshotStoreMode;

package eventsrc4j.io;


/**
 * Implementations of this interface deal with persisting snapshots for a specific key.
 *
 * @param <V> The type of the value wrapped by Snapshots that this store persists.
 */
public interface SnapshotStream<S, V> {

  /**
   * Retrieve a snapshot before the given sequence number. We typically specify a sequence number if we want to get
   * some old snapshot i.e. the latest persisted snapshot may have been generated after the point in time that we're
   * interested in.
   *
   * @param sequence What sequence we want to get the snapshot for (earliest snapshot, latest, or latest before some sequence)
   * @return The snapshot, a NoSnapshot if there was no snapshot for the given conditions.
   */
  IO<Snapshot<S, V>> get(SequenceQuery<S> sequence);

  /**
   * Save a given snapshot
   * @param snapshot The snapshot to save
   * @param mode Defines whether the given snapshot should be deemed the earliest point in the event stream (Epoch) or not (Cache)
   * @return the saved snapshot.
   */
  IO<Snapshot<S, V>> put(Snapshot<S, V> snapshot, SnapshotStoreMode mode);