Annotation Constructors: factory()

Indicates that class has to be instantiated using a given factory function.
factory() annotation takes declaration of top-level factory function.

Factory function arguments

Example of synchronous instantiation:

    StarshipTest createStarshipTest() => StarshipTest(universeSize);

    factory(`function createStarshipTest`)
    class StarshipTest(Integer universeSize) {
        ...
    }       

Example of asynchronous instantiation:

    StarshipTest createStarshipTest(AsyncFactoryContext context) {
        context.fill(StarshipTest(universeSize));
    }

    factory(`function createStarshipTest`)
    class StarshipTest(Integer universeSize) {
        ...
    }       

Pay attention:
Asynchronous version has to call AsyncFactoryContext.fill() or AsyncFactoryContext.abort().
Synchronous version has to return non-optional object or throw.

By: Lis
Since 0.6.0
  • FactoryAnnotation
    • Basic
      • Identifiable
      • Object
        • Anything
    • OptionalAnnotation
      • ConstrainedAnnotation
        • Annotation

no subtypes hierarchy

Initializer
FactoryAnnotation(FunctionDeclaration factoryFunction)
Parameters:
  • factoryFunction

    Function used to instantiate anotated class.
    Has to return an instance of the looking class.

Attributes
factoryFunctionshared FunctionDeclaration factoryFunction

Function used to instantiate anotated class.
Has to return an instance of the looking class.

Inherited Attributes
Attributes inherited from: Object
hash, string
Inherited Methods
Methods inherited from: Object
equals