I need a complex Matcher
for byte[]
. The code below does not compile since argThat
returns Byte[]
. Is there a way to write a dedicated Matcher
for an array of primitive types?
verify(communicator).post(Matchers.argThat(new ArgumentMatcher<Byte[]>() {
@Override
public boolean matches(Object argument) {
// do complex investigation of byte array
return false;
}
}));
You really can use
new ArgumentMatcher<byte[]> { ... }
here:The answers you are referring to say that
byte[]
is not a valid substitute forT[]
(becauseT[]
assumesObject[]
, whichbyte[]
is not), but in your case there is noT[]
involved, andbyte[]
, being a subclass ofObject
, is a valid substitute for simpleT
.