Last active
April 26, 2019 22:20
-
-
Save zeryx/6750b68cfc9d68cff3c6fa03a8324c91 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.org.example; | |
import java.util.HashMap; | |
/** | |
* Hello world! | |
* | |
*/ | |
class AlgorithmBasic | |
{ | |
String foo(String input, HashMap<String, String> l) throws RuntimeException{ | |
return "hello ".concat(input); | |
} | |
Integer bar() throws RuntimeException{ | |
return 1; | |
} | |
public static void main(String[] args) throws Exception{ | |
AlgorithmBasic defs = new AlgorithmBasic(); | |
AlgorithmHandler algo = new AlgorithmHandler<>(defs::foo); | |
algo = algo.setLoad(defs::bar); | |
algo.run(); | |
} | |
} |
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.org.example; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
public class AlgorithmHandler<INPUT, STATE, OUTPUT> { | |
private BiFunction<INPUT, STATE, OUTPUT> applyFuncState; | |
private Supplier<STATE> loadFunc; | |
private STATE state; | |
public AlgorithmHandler(BiFunction<INPUT,STATE, OUTPUT> applyFunc, Supplier<STATE> loadFunc){ | |
this.applyFuncState = applyFunc; | |
this.loadFunc = loadFunc; | |
} | |
public AlgorithmHandler(BiFunction<INPUT, STATE, OUTPUT> applyFunc) throws Exception{ | |
this.applyFuncState = applyFunc; | |
} | |
public AlgorithmHandler setLoad(Supplier<STATE> func) throws Exception{ | |
loadFunc = func; | |
return this; | |
} | |
public void run() throws Exception{ | |
System.out.println("Not implemented"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment