Created
September 9, 2015 12:35
-
-
Save dhaeb/c22832d6d9c530f0e264 to your computer and use it in GitHub Desktop.
Java 8 - Function abstraction can be difficult. Any Ideas to make it better?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("unchecked") // It's a cast, I am responsible. | |
private void callToMethod(int i, int j) { | |
if(f instanceof BiFunction){ | |
BiFunction<Integer, Integer, Boolean> callable = (BiFunction<Integer, Integer, Boolean>) f; | |
callable.apply(0, 1); | |
} else if(f instanceof BiConsumer){ | |
BiConsumer<Integer, Integer> callable = (BiConsumer<Integer, Integer>) f; | |
callable.accept(i, j); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment