Changes in DI ListBuilder API

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Changes in DI ListBuilder API

Nikita Timofeev
Hi all,

One more thing I want to change in the existing DI API.
This time it's about creating ordered List binding.

There are some problems and ambiguities with new 4.0 DI API for adding
ordered dependencies:
  1) you can call after() / before() without adding anything first,
that will cause NPE
  2) right order of calls is not clear: add().after() or after().add()

Suggested API modification:

  1) remove UnorderedListBuilder, keep everything in ListBuilder
  2) add methods with explicit before\after parameters:

    ListBuilder<T> addAfter(Class<? extends T> interfaceType, Class<?
extends T> afterType);

    ListBuilder<T> addAfter(T value, Class<? extends T> afterType);

    ListBuilder<T> addAllAfter(Collection<T> values, Class<? extends
T> afterType);
    ListBuilder<T> insertBefore(Class<? extends T> interfaceType,
Class<? extends T> beforeType);
    ListBuilder<T> insertBefore(T value, Class<? extends T> beforeType);
    ListBuilder<T> insertAllBefore(Collection<T> values, Class<?
extends T> beforeType);


--
Best regards,
Nikita Timofeev
Loading...