classafIoc::OrderedConfig

sys::Obj
  afIoc::OrderedConfig

Passed into module contribution methods to allow the method to, err, contribute!

A service can collect contributions in three different ways:

  • As an unordered list of values
  • As an ordered list of values
  • As a map of keys and values

The service defines the type of contribution by declaring a parameterised list or map in its ctor or builder method. Contributions must be compatible with the type.

@see TypeCoercer

add

Source

@Operator
This add(Obj object)

Adds an unordered object to a service's configuration. An attempt is made to coerce the object to the contrib type.

addAll

Source

This addAll(Obj[] objects)

Adds all the unordered objects to a service's configuration. An attempt is made to coerce the objects to the contrib type.

addOrdered

Source

This addOrdered(Str id, Obj? value, Str[] constraints := Str[])Str#.emptyList()

Adds an ordered object to a service's contribution. Each object has a unique id (case insensitive) that is used by the constraints for ordering. Each constraint must start with the prefix BEFORE: or AFTER:.

config.addOrdered("Breakfast", eggs)
config.addOrdered("Dinner", pie)
config.addOrdered("Lunch", ham, ["AFTER: breakfast", "BEFORE: dinner"])

Configuration contributions are ordered across modules.

An attempt is made to coerce the object to the contrib type.

addOverride

Source

This addOverride(Str existingId, Obj? newValue, Str[] newConstraints := Str[])Str#.emptyList(, Str? newId := null)

Overrides a contributed ordered object. The original object must exist. An attempt is made to coerce the override to the contrib type.

Note: Unordered configurations can not be overridden.

Note: If a newId is supplied then this override itself may be overridden by other contributions. 3rd party libraries, when overriding, should always supply a newId.

@since 1.2.0

addPlaceholder

Source

This addPlaceholder(Str id, Str[] constraints := Str[])Str#.emptyList()

Adds a placeholder. Placeholders are empty configurations used to aid ordering.

config.addPlaceholder("End")
config.addOrdered("Wot", ever, ["BEFORE: end"])
config.addOrdered("Last", last, ["AFTER: end"])

Placeholders do not appear in the the resulting ordered list.

@since 1.2.0

autobuild

Source

Obj autobuild(Type type, Obj?[] ctorArgs := Obj#.emptyList())

A helper method that instantiates an object, injecting any dependencies. See Registry.autobuild.

remove

Source

This remove(Str existingId, Str? newId := null)

A special kind of override whereby, should this be the last override applied, the value is removed from the configuration.

Note: If a newId is supplied then this override itself may be overridden by other contributions. 3rd party libraries, when overriding, should always supply a newId.

@since 1.4.0

toStr

Source

virtual override Str toStr()