Property | Defined By | ||
---|---|---|---|
decorateNull : Boolean
Whether to decorate null values. | LookupDecorator | ||
decorator : ILookupDecorator
The decorator to use. | LookupDecorator | ||
nullIsFallback : Boolean
Whether to continue in the chain if a chain link yiels null. | LookupDecorator |
Method | Defined By | ||
---|---|---|---|
LookupDecorator(forItem:Class, implementation:Class, decorator:ILookupDecorator, decorateNull:Boolean = false, nullIsFallback:Boolean = false)
Utility class which enables convenient decoration of look-up chains on top of a given
ILookupDecorator. | LookupDecorator | ||
hideImplementation(predicate:Function = null):IContextLookupChainLink
Creates a chain link which always returns null when an implementation
of the asked type is requested. | LookupDecorator | ||
setFactory(factory:Function, predicate:Function = null):IContextLookupChainLink
Creates a chain link and decorates the decorator with it. | LookupDecorator | ||
setImplementationWrapper(wrapperFactory:Function, predicate:Function = null):IContextLookupChainLink
Creates a chain link which returns an implementation of the asked type which
wraps the default (actually the recently added chain link for the same item and
implementation type). | LookupDecorator | ||
setInstance(instance:Object, predicate:Function = null):IContextLookupChainLink
Creates a chain link which returns the given instance when asked for the item and
implementation type this LookupDecorator is created for. | LookupDecorator |
decorateNull | property |
decorateNull:Boolean
Whether to decorate null
values.
If set to true
wrappers created by the wrapper factory set by
setImplementationWrapper()
will be created even if they wrap
a null
value. If set to false
, a null
value
won't be wrapped; instead null
will be returned.
Setting a different value will not affect existing chain links.
public function get decorateNull():Boolean
public function set decorateNull(value:Boolean):void
decorator | property |
decorator:ILookupDecorator
The decorator to use.
Setting a different value will not affect existing chain links.
public function get decorator():ILookupDecorator
public function set decorator(value:ILookupDecorator):void
nullIsFallback | property |
nullIsFallback:Boolean
Whether to continue in the chain if a chain link yiels null
.
If a factory method (set by setFactory()
) yields
null
the search in the lookup chain will be continued if this
value is set to true
. This is equivalent to use the default
implementaion as fallback.
Setting a different value will not affect existing chain links.
public function get nullIsFallback():Boolean
public function set nullIsFallback(value:Boolean):void
LookupDecorator | () | Constructor |
public function LookupDecorator(forItem:Class, implementation:Class, decorator:ILookupDecorator, decorateNull:Boolean = false, nullIsFallback:Boolean = false)
Utility class which enables convenient decoration of look-up chains on top of a given
ILookupDecorator
.
forItem:Class — The item class to decorate.
| |
implementation:Class — The type of implementation which is looked up for.
| |
decorator:ILookupDecorator — The decorator to use.
| |
decorateNull:Boolean (default = false ) — Whether calls that yield null will be decorated
by wrapper factories set by setImplementationWrapper() .
| |
nullIsFallback:Boolean (default = false ) — If a factory method (set by setFactory() ) yields
null the search in the lookup chain will be continued if this
value is set to true , otherwise null will be returned.
|
hideImplementation | () | method |
public function hideImplementation(predicate:Function = null):IContextLookupChainLink
Creates a chain link which always returns null
when an implementation
of the asked type is requested. This will efficiently disable the default.
A predicate function function( item:Object ):Boolean
will be queried
whether to return null
for the given item or to continue searching in the chain.
If no predicate is given the created link will always return
null
if the correct type is asked for the given item.
Parameters
predicate:Function (default = null ) — A predicate method which will return true if null should
be returned for the given item. If no predicate is provided null will
always be returned.
|
IContextLookupChainLink — The chain link which is created and added to the lookup chain.
|
setFactory | () | method |
public function setFactory(factory:Function, predicate:Function = null):IContextLookupChainLink
Creates a chain link and decorates the decorator with it.
The chain link delegates to the given factory method function( item:Object ):Object
which creates an implementation of the asked type for the given item.
A predicate function function( item:Object ):Boolean
will be queried
whether to invoke the factory for the given item or to continue searching in the chain
(using the default). If no predicate is given, the factory will always be employed
if the correct type is asked for the given item.
If nullIsFallback
is set to true
the link will continue searching
in the chain if the factory returns null
.
Parameters
factory:Function — A factory method to create an object for the given item.
| |
predicate:Function (default = null ) — A predicate method which will return true if the factory
should be invoked for the given item. If no predicate is provided, the factory will
always be invoked.
|
IContextLookupChainLink — The chain link which is created and added to the lookup chain.
|
setImplementationWrapper | () | method |
public function setImplementationWrapper(wrapperFactory:Function, predicate:Function = null):IContextLookupChainLink
Creates a chain link which returns an implementation of the asked type which wraps the default (actually the recently added chain link for the same item and implementation type).
The chain link delegates to the given factory method
function( item:Object, default:Object ):Object
which creates an implementation of the asked type for the given item which wraps the given
default implementation.
A predicate function function( item:Object ):Boolean
will be queried
whether to invoke the factory for the given item or return the default. If no predicate
is given, the factory will always be employed if the correct type is asked for the given item.
If decorateNull
is set to true
a null
default
will be wrapped, too. Otherwise, null
will be returned if the default
is null
, too.
Parameters
wrapperFactory:Function — The factory method which wraps a given implementation.
| |
predicate:Function (default = null ) — A function which returns true if the default
should be wrapped for the given item. If no predicate is given, the default
will always be wrapped.
|
IContextLookupChainLink — The chain link which is created and added to the lookup chain.
|
setInstance | () | method |
public function setInstance(instance:Object, predicate:Function = null):IContextLookupChainLink
Creates a chain link which returns the given instance when asked for the item and
implementation type this LookupDecorator
is created for.
This allows to use a shared instance which does not have to be configured for the item.
Developers have to make sure that the object is an implementation of the implementation
type this LookupDecorator
is created for.
A predicate function function( item:Object ):Boolean
will be queried
whether to invoke the factory for the given item or return the default. If no predicate
is given, the factory will always be employed if the correct type is asked for the given item.
Parameters
instance:Object — The instance to return.
| |
predicate:Function (default = null ) — A function which returns true if the given instance
should be returned for the given item. If no predicate is given, the given instance
will always be returned.
|
IContextLookupChainLink — The chain link which is created and added to the lookup chain.
|