public interface ByteConsumer{ // Method 1 default <T> T consume(T consumer) throws IOException{ return consume(consumer); } // Method 2 default <T extends BaseToBytes> T consume(T consumer) throws IOException { consume(consumer.getInputStream()); return consumer; } void consume(InputStream input) throws IOException; }
@Override default <T> T consume(T consumer) throws IOException{ //noinspection unchecked return (T) consume((BaseToBytes)consumer); }