package Ġio . github . ab addon . kc q rs . examples . counter InMemory . repository Ċ Ċ import Ġio . github . ab addon . kc q rs . core . I Identity Ċ import Ġio . github . ab addon . kc q rs . core . domain . messages . events . ID omain Event Ċ import Ġio . github . ab addon . kc q rs . core . persistence . Event Store Repository Ċ import Ġio . github . ab addon . kc q rs . core . projection s . I Projection Ċ import Ġio . github . ab addon . kc q rs . core . projection s . I Projection Handler Ċ import Ġio . github . ab addon . kc q rs . examples . counter InMemory . entities . Counter Aggregate Id Ċ import Ġio . github . ab addon . kc q rs . examples . counter InMemory . entities . Counter Aggregate Root Ċ import Ġorg . slf 4 j . Logger Ċ import Ġorg . slf 4 j . LoggerFactory Ċ Ċ class ĠCounter Aggregate Repository () Ġ: ĠEvent Store Repository < Counter Aggregate Root >() Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġlog : ĠLogger Ġ= ĠLoggerFactory . getLogger ( this . java Class . simple Name ) ĊĊĠĠĠ Ġprivate Ġval Ġstorage Ġ= Ġmutable Map Of < String , ĠMutable List < ID omain Event >>() ĊĊĠĠĠ Ġoverride Ġfun Ġ< T Projection Ġ: ĠI Projection > Ġsubscribe ( projection Handler : ĠI Projection Handler < T Projection >) Ġ{ ĊĠĠĠĠĠĠĠ ĠTODO (" Not Ġyet Ġimplemented ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġempty Aggregate ( aggregate Id : ĠI Identity ): ĠCounter Aggregate Root Ġ= ĊĠĠĠĠĠĠĠ ĠCounter Aggregate Root ( aggregate Id Ġas ĠCounter Aggregate Id , Ġ 0 L , Ġ 0 , ĠArrayList < ID omain Event >()) ĊĊĠĠĠ Ġoverride Ġfun Ġaggregate Id Stream Name ( aggregate Id : ĠI Identity ): ĠString Ġ= Ġaggregate Id . value AsString () ĊĊĠĠĠ Ġoverride Ġfun Ġload ( stream Name : ĠString , Ġstart From : ĠLong ): ĠList < ID omain Event > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġstorage . get OrDefault ( stream Name , listOf ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġpersist ( ĊĠĠĠĠĠĠĠ Ġstream Name : ĠString , ĊĠĠĠĠĠĠĠ Ġun committed Events : ĠList < ID omain Event >, ĊĠĠĠĠĠĠĠ Ġheader : ĠMap < String , ĠString >, ĊĠĠĠĠĠĠĠ Ġcurrent Version : ĠLong ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrent Events = storage . get OrDefault ( stream Name , listOf ()). to Mutable List () ĊĠĠĠĠĠĠĠ Ġcurrent Events . addAll ( un committed Events . to Mutable List ()) ĊĠĠĠĠĠĠĠ Ġstorage [ stream Name ]= Ġcurrent Events ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġpublish ( events : ĠList < ID omain Event >) Ġ{} Ċ }