sageserpent-open / plutonium

CQRS providing bitemporal object modelling for Java POJOs and Scala too.
MIT License
5 stars 0 forks source link

Simplify client code interaction with bitemporal objects. #53

Open sageserpent-open opened 5 years ago

sageserpent-open commented 5 years ago

Currently all bitemporal objects are rendered into streams of matching items by a scope - these may be empty, or yield one or more objects. We already have distinct bitemporals for an expected number of yielded items, these should return more specific types than just a stream.

So 'Scope.render' would be furnished with overloads that return, say:-

zeroOrOne[X] ----> Option[X]

atLeastOne[X] ----> Nel[X]

one[X] ----> X

This then avoids the tedious '.head' calls that are currently scattered around the codebase, and which act as a barrier to comprehending the API.