Last active
July 27, 2020 08:43
-
-
Save vasuadari/c47f96fdc5daafe1435afd9f902509d0 to your computer and use it in GitHub Desktop.
Sample Template Design Pattern
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
// src: https://www.javatpoint.com/template-pattern | |
public interface Base { | |
boolean supports(EventModel event); | |
void apply(EventModel event); | |
} | |
// All different types of classes can implement this Base. | |
// ClassA – Base | |
// ClassB – Base | |
Class DefaultHandler | |
List<Base> base | |
Process function: | |
// Iterate the class list & handle all request. | |
private void handle (params) { | |
if (base.supports(event)) { | |
base.apply(event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment