Anonymous - 2010-06-06

The reason I made the signature for eq to be used like this:

eq(param, param.getString(), "hi")

was so there would be no problems matching the argument type. This would make the signature of eq this:

public static <T, P=""> T eq(T matcher, P actual, P expected)

It would be nicer if I didn't actually have to pass in the matcher, making the call look like this:

eq(param.toString(), "hi")

The problem with this is that the return type of eq cannot be inferred from the parameters being passed into eq. That is why I included the matcher originally in the request. To use this alternate method would make the signature of eq this:

public static <T, P=""> T eq(P actual, P expected)

I've at times had trouble with Java guessing the correct return type for existing matchers like anyObject(), I've had to resort to a type cast. But maybe it's worth the occasional typecast if it makes the syntax more concise.

Also, this new argument matcher object should really be treated as an argument matcher factory, really. Even in the original examples, it actually produces multiple argument matcher instances. Maybe a better name for it would be createArgumentRecorder, and that thing assists in creating argumentMatchers through the methods like eq(...).