Producers

Four ways to get objects into the Pixie System

Pixie supports four ways to create and register components in the System. Each approach gives you a different level of control over how objects are constructed.

ProducerHow It WorksWhen To Use
ConstructorPixie calls an annotated constructor directlySimple classes you own
Factory MethodA @Factory static method creates the instancePrivate constructors, validation, or classes you don’t own
BuilderA @Builder static method returns a builder with annotated settersComplex construction with many optional parameters
Pre-built InstanceYou create the object and hand it to system.add()Third-party objects, test doubles, or runtime-computed values

When a class has both a @Factory method and a @Builder method, Pixie will prefer the @Factory. If neither annotation is present, Pixie falls back to the constructor.