diff --git a/core/shared/src/main/scala/works/iterative/core/service/Factory.scala b/core/shared/src/main/scala/works/iterative/core/service/Factory.scala deleted file mode 100644 index a92e8cc..0000000 --- a/core/shared/src/main/scala/works/iterative/core/service/Factory.scala +++ /dev/null @@ -1,22 +0,0 @@ -package works.iterative.core -package service - -import zio.* - -/** Generic class for entity factories. - * - * Creates a new entity from a "seed". - */ -trait EntityFactory[Entity, Seed]: - def make(seed: Seed): IO[UserMessage, Entity] - -/** A factory using idGenerator to create the entity */ -class GeneratingFactory[Entity, Seed, Id]( - constructor: Seed => Validated[Id => Entity], - idGenerator: IdGenerator[Id] -) extends EntityFactory[Entity, Seed]: - override def make(seed: Seed): IO[UserMessage, Entity] = - for - construct <- constructor(seed).toZIO - id <- idGenerator.nextId - yield construct(id) diff --git a/core/shared/src/main/scala/works/iterative/core/service/Factory.scala b/core/shared/src/main/scala/works/iterative/core/service/Factory.scala deleted file mode 100644 index a92e8cc..0000000 --- a/core/shared/src/main/scala/works/iterative/core/service/Factory.scala +++ /dev/null @@ -1,22 +0,0 @@ -package works.iterative.core -package service - -import zio.* - -/** Generic class for entity factories. - * - * Creates a new entity from a "seed". - */ -trait EntityFactory[Entity, Seed]: - def make(seed: Seed): IO[UserMessage, Entity] - -/** A factory using idGenerator to create the entity */ -class GeneratingFactory[Entity, Seed, Id]( - constructor: Seed => Validated[Id => Entity], - idGenerator: IdGenerator[Id] -) extends EntityFactory[Entity, Seed]: - override def make(seed: Seed): IO[UserMessage, Entity] = - for - construct <- constructor(seed).toZIO - id <- idGenerator.nextId - yield construct(id) diff --git a/core/shared/src/main/scala/works/iterative/entity/EntityFactory.scala b/core/shared/src/main/scala/works/iterative/entity/EntityFactory.scala new file mode 100644 index 0000000..b2fef3a --- /dev/null +++ b/core/shared/src/main/scala/works/iterative/entity/EntityFactory.scala @@ -0,0 +1,24 @@ +package works.iterative.entity + +import works.iterative.core.Validated +import works.iterative.core.UserMessage +import works.iterative.core.service.IdGenerator +import zio.* + +/** Generic class for entity factories. + * + * Creates a new entity from a "seed". + */ +trait EntityFactory[Entity, Seed]: + def make(seed: Seed): IO[UserMessage, Entity] + +/** A factory using idGenerator to create the entity */ +class GeneratingFactory[Entity, Seed, Id]( + constructor: Seed => Validated[Id => Entity], + idGenerator: IdGenerator[Id] +) extends EntityFactory[Entity, Seed]: + override def make(seed: Seed): IO[UserMessage, Entity] = + for + construct <- constructor(seed).toZIO + id <- idGenerator.nextId + yield construct(id)