Skip to content

Instantly share code, notes, and snippets.

@theomega
Created January 11, 2016 08:49
Show Gist options
  • Save theomega/8fe4b125e75ac2e6d1a8 to your computer and use it in GitHub Desktop.
Save theomega/8fe4b125e75ac2e6d1a8 to your computer and use it in GitHub Desktop.
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