I have this following two functional interfaces:
IndexBytePairConsumer.java
package me.theeninja.nativearrays.core;
@FunctionalInterface
public interface IndexBytePairConsumer {
void accept(long index, byte value);
}
IndexIntPairConsumer.java
package me.theeninja.nativearrays.core;
@FunctionalInterface
public interface IndexIntPairConsumer {
void accept(long index, int value);
}
I also have the following method:
public void forEachIndexValuePair(IndexBytePairConsumer indexValuePairConsumer) {
...
}
Is there any way I can allow an IndexIntPairConsumer
to be passed in the above method (since a consumer of ints can accept bytes)? I'm required to use primitives in the method signatures rather than the associated classes such as Integer
and Byte
, so any abstraction becomes much more difficult.