Liking cljdoc? Tell your friends :D

midje.util.ordered-deftype

This code was copied from an earlier version of the ordered library, https://github.com/flatland/ordered, because of a version conflict. That library is covered by the Eclipse Public License, V1.0, which you can find in Midje's root directory.

This code was copied from an earlier version of the ordered library,
`https://github.com/flatland/ordered`, because of a version conflict.
That library is covered by the Eclipse Public License, V1.0, which
you can find in Midje's root directory.
raw docstring

delegating-deftypecljmacro

(delegating-deftype cname [& fields] delegate-map & deftype-args)

Shorthand for defining a new type with deftype, which delegates the methods you name to some other object or objects. Delegates are usually a member field, but can be any expression: the expression will be evaluated every time a method is delegated. The delegate object (or expression) will be type-hinted with the type of the interface being delegated.

The delegate-map argument should be structured like: {object-to-delegate-to {Interface1 [(method1 []) (method2 [foo bar baz])] Interface2 [(otherMethod [other])]}, another-object {Interface1 [(method3 [whatever])]}}.

This will cause your deftype to include an implementation of Interface1.method1 which does its work by forwarding to (.method1 object-to-delegate-to), and likewise for the other methods. Arguments will be forwarded on untouched, and you should not include a this parameter. Note especially that you can have methods from Interface1 implemented by delegating to multiple objects if you choose, and can also include custom implementations for the remaining methods of Interface1 if you have no suitable delegate.

Arguments after delegate-map are as with deftype, although if deftype ever has options defined for it, delegating-deftype may break with them.

Shorthand for defining a new type with deftype, which delegates the methods
you name to some other object or objects. Delegates are usually a member field,
but can be any expression: the expression will be evaluated every time a method
is delegated. The delegate object (or expression) will be type-hinted with the
type of the interface being delegated.

The delegate-map argument should be structured like:
{object-to-delegate-to {Interface1 [(method1 [])
                                    (method2 [foo bar baz])]
                        Interface2 [(otherMethod [other])]},
 another-object {Interface1 [(method3 [whatever])]}}.

This will cause your deftype to include an implementation of Interface1.method1
which does its work by forwarding to (.method1 object-to-delegate-to), and
likewise for the other methods. Arguments will be forwarded on untouched, and
you should not include a `this` parameter. Note especially that you can have
methods from Interface1 implemented by delegating to multiple objects if you
choose, and can also include custom implementations for the remaining methods of
Interface1 if you have no suitable delegate.

Arguments after `delegate-map` are as with deftype, although if deftype ever has
options defined for it, delegating-deftype may break with them.
sourceraw docstring

delegating-reifycljmacro

(delegating-reify delegate-map & reify-args)

Like delegating-deftype, but creates a reify body instead of a deftype.

Like delegating-deftype, but creates a reify body instead of a deftype.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close