DomainRepository in Java 8

Hi all,

I’d like to implement a DomainRepository in Java 8 but I can’t find any example of a DomainRepository interacting with EventStore to get and save aggregates written in Java 8.

Is there someone that can point me to an article or example project? BTW Google is full of articles “talking” about it but I can’t find an example of code.

Is that because is less common to use such a pattern in Java?



Its just read from stream and append ...

and writing events

The java 8 api is almost identical


Hi Greg,

thanks for the links. The DomainRepository idea is straight forward: GetById, Save. It accepts any Aggregate specified as generic type by the client. The difficulties are more related to “how do that in pure Java”. I can imagine this can be implemented easily with Scala or Kotlin. But using just Java how you do something like that C#:

protected TResult BuildAggregate(IEnumerable events) where TResult : IAggregate, new()


var result = new TResult();

foreach (var @event in events)




return result;


You cannot instantiate generic types in that way and there is not a language constraints like : where… new().

We think that maybe in Java there are other ways to do that maybe simpler but we cannot find an example of a generic DomainRepository.