Quoting Niclas Hedhman <[email protected]>:

On Fri, Sep 23, 2011 at 6:02 PM, Niclas Hedhman <[email protected]> wrote:
Ok, thanks for your feedback. I'll look into if the second case is
deterministic or if it may select the other constructor...

At the moment, the constructors are sorted according to number of
constructor arguments, with the most arguments 'first', after
non-useful constructors have been filtered out.

So, the potentially non-deterministic behavior occurs if there are
multiple constructors with the same number of arguments.

Stuart; Does clazz.getDeclaredConstructors() have any specification
level ordering? (I noticed that changing the constructor ordering in
the source code didn't affect the order which they were returned, with
more arguments first)


Any ideas?



This is not directly related to this but IMO:

1. making these complex rules is error-prone and may scare newcomers, and
2. wrapping two same-type parameters into their own interface (eg two Map<,> parameters) for the @Uses is quite annoying.

How about replacing @Uses with something that can handle multiple arguments with same type? For example, @NamedParameter("name"). Or @First, @Second, @Third, etc... or make using annotations optional, and only use them to separate the two same-type parameters? (ie assume that all non-annotated parameters automatically are used like @Uses)

Like this:

public MyClass(String param1, @MyStringMap Map<String, String> param2, @MyClassMap Map<Class<?>, String> param3) { ... }

which would be used like this:

MyClass obj = someBuilder
  .use("Param1")
  .useWithAnnotation(MyStringMap.class, new HashMap<String, String>())
  .useWithAnnotation(MyClassMap.class, new HashMap<Class<?>, String>())
  .newInstance();


_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to