mercredi 5 juillet 2017

Strategy pattern - How to maintain different strategies in Java8 using lambdas

I have a class like below which contains different strategies.

public class Lambdas {

    public static final Consumer<String> STRATEGY1 = (s) -> {};
    public static final Consumer<String> STRATEGY2 = (s) -> {};
    public static final Consumer<String> STRATEGY3 = (s) -> {};
    public static final Consumer<String> STRATEGY4 = (s) -> {}; 
    public static final Consumer<String> STRATEGY5 = (s) -> {};
    public static final Consumer<String> STRATEGY6 = (s) -> {}; 

} 

It works fine for me. But, I would like to know the best practice you all follow in maintaining different strategies using lambdas in Java8.

Aucun commentaire:

Enregistrer un commentaire