Created
January 1, 2020 04:52
-
-
Save joshiraez/bec9c60cb96e8cbde85f8f0f3472b924 to your computer and use it in GitHub Desktop.
How would you create classic instances using this aproach, creating a factory. "Rethinking interfaces"
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
class OperationWithOperationData { | |
Predicate<String> isOperation; | |
IntBinaryOperator reductionOperation; | |
List<Integer> toOperateOn; | |
private OperationWithOperationData() {}; | |
public static Function< | |
List<Integer>, | |
OperationWithOperationData | |
> of( | |
Predicate<String> isOperation, | |
IntBinaryOperator reductionOperation | |
){ | |
return toOperateOn -> | |
{ | |
OperationWithOperationData toBuild = new OperationWithOperationData(); | |
toBuild.isOperation = isOperation; | |
toBuild.reductionOperation = reductionOperation; | |
toBuild.toOperateOn = toOperateOn; | |
return toBuild; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment