Created
January 11, 2016 08:49
-
-
Save theomega/8fe4b125e75ac2e6d1a8 to your computer and use it in GitHub Desktop.
This file contains 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
package com.company; | |
public class Main { | |
public static void main(String[] args) { | |
ThreeParameterFunction<Integer, Integer, String> cbi = ((currentIndex, maxIndex, wisdom) -> | |
System.out.println("Executed run " + currentIndex + " of " + maxIndex + " Wisdom: " + wisdom) | |
); | |
SomeOtherPackageThreeParameterFunction<Integer, Integer, String> socbi = ((currentIndex, maxIndex, wisdom) -> | |
System.out.println("This is similar; run " + currentIndex + " of " + maxIndex + " Wisdom: " + wisdom) | |
); | |
executeNTimes(10, socbi::run); | |
} | |
public static void executeNTimes(int n, ThreeParameterFunction<Integer, Integer, String> f) { | |
for (int i = 0; i < n; i++) { | |
f.run(i, n, "current daily wisdom"); | |
} | |
} | |
private interface ThreeParameterFunction<A, B, C> { | |
void run(A a, B b, C c); | |
} | |
// Assume some other package defines this interface and uses it for some premade function | |
private interface SomeOtherPackageThreeParameterFunction<A, B, C> { | |
void run(A a, B b, C c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment