EntityFactory

scalata.application.services.EntityFactory
trait EntityFactory[F <: EntityFactory[F, E, P], E, P]

Generic factory type-class able to build domain entities.

==== Type parameters ====

  • F – concrete factory that implements the trait (self-type used for fluent APIs).
  • E – entity returned by the factory (e.g. Enemy, Item).
  • P – descriptor specifying which concrete subtype to create (enum, string tag, config object …).

Implementations are pure: calling create must not mutate shared state but simply return a fresh instance of E.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def create(entityType: P, id: String): E

Produce a new entity of the requested kind.

Produce a new entity of the requested kind.

Value parameters

entityType

discriminator telling the factory which subtype to build

id

stable identifier; empty string lets the factory auto-generate one

Attributes

Returns

a brand-new instance of E