Skip to content

Instantly share code, notes, and snippets.

@vasuadari
Last active July 27, 2020 08:43
Show Gist options
  • Save vasuadari/c47f96fdc5daafe1435afd9f902509d0 to your computer and use it in GitHub Desktop.
Save vasuadari/c47f96fdc5daafe1435afd9f902509d0 to your computer and use it in GitHub Desktop.
Sample Template Design Pattern
// 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