mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
* chore: create behavioral design patterns package * doc: add chain of responsibility documentation * doc: add behavioral package table of content * doc: edit general doc * add code example Co-authored-by: Ruidy <r.nemausat@empfohlen.de>
19 lines
452 B
Python
19 lines
452 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Optional, Any
|
|
|
|
|
|
class Handler(ABC):
|
|
"""
|
|
The Handler interface declares a method for building the chain of handlers.
|
|
It also declares a method for executing a request.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def set_next(self, handler: Handler) -> Handler:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def handle(self, request: Any) -> Optional[str]:
|
|
pass
|