The Java guide says
"So when should you use varargs? ...
As an API designer, you should use them sparingly, only when the benefit
is truly compelling. Generally speaking, you should not overload a
varargs method, or it will be difficult for programmers to figure out
which overloading gets called."
<
http://java.sun.com/javase/6/docs/technotes/guides/language/varargs.html>
Marc and I both had difficulty figuring out which overloaded build(...) method was called, just as this advice talks about.
Perhaps it would be better to remove build(Object... values). Or rename it.
build(Map<String,?> values) can be used instead.
With a build(Map<String,?>) method, calling build(m) can still invoke the build(Object...) method even when m is a Map whose keys and values are Strings.
Here is an example that surprisingly invokes build(Object...). It is contrived, but removing/renaming the varargs method would avoid confusion.
Map<String,String> values = new HashMap<String,String>();
values.put("bar", "foo");
Map<? super String,String> v = values;
ub.build(v);
Which is invoked if the caller uses a Map without generics?
James Manger