Closed aaschmid closed 10 years ago
@michaeladler can you tell me if that is what you wanted? Do you maybe have an idea for a better naming for the methods?
Yes, this goes in the right direction. Maybe two additional convenience methods:
public static <T> Object[][] toObjectArray( T... input ) {}
public static <T> Object[][] toObjectArray( Iterable<T> input ) {}
Then, instead of
$$($("foo"), $("bar"))
you can write
toObjectArray("foo", "bar")
I quite like the method name "$" since it is very short and thus makes it easy to read the code (since it is used very often). The method $$ is generally used only once so you could just call it "merge" - it merges the given Object[] arrays.
Ok, good points :-)
I have just seen that method
public static Object[][] testForEach(Object... args)
is what you want with toObjectArray("foo", "bar")
, isn't it?
And I like $$
for object arrays as it is like $
for objects, however merge
is a good name either.
I will think about it ...
Oh, now I understand... I actually considered this test code that you would remove in the final version :-) You are right, that's what I was looking for. Maybe you should just drop the prefix "test".
Yes, you may be right, I have also thought about that. Shouldn't we than change the name of the class to something more meaningful like DataProviders
(as guava does for its helpers) or Tests
? I don't know because most of the time you will statically import these methods, wouldn't you?
Personally I prefer to import all static methods so that I don't have to prefix the class ;-) In that case calling the method "forEach" is probably too general. How about "toSingletonProvider" or something like that. I know, it's hard to find a good name.
Yes, it indeed is ... that's why I ask ...
@michaeladler If you want, you can review the changes and if they are ok, I will merge it into master
branch. I have kept the naming for now, hope that's OK, although I also like toSingletonProvider
(but not as much as testForEach
)
$(...)
method as a shortcut for creating an array ofObject
s from varargs.Object[][]
for all enums in a classObject
, e.g.<T> Object[][] method(Iterable<T> args / T ... args) { ... }