MCPcopy Create free account
hub / github.com/RefactoringGuru/design-patterns-python / State

Class State

src/State/Conceptual/main.py:63–90  ·  view source on GitHub ↗

EN: The base State class declares methods that all Concrete State should implement and also provides a backreference to the Context object, associated with the State. This backreference can be used by States to transition the Context to another State. RU: Базовый класс Состояни

Source from the content-addressed store, hash-verified

61
62
63class State(ABC):
64 """
65 EN: The base State class declares methods that all Concrete State should
66 implement and also provides a backreference to the Context object,
67 associated with the State. This backreference can be used by States to
68 transition the Context to another State.
69
70 RU: Базовый класс Состояния объявляет методы, которые должны реализовать все
71 Конкретные Состояния, а также предоставляет обратную ссылку на объект
72 Контекст, связанный с Состоянием. Эта обратная ссылка может использоваться
73 Состояниями для передачи Контекста другому Состоянию.
74 """
75
76 @property
77 def context(self) -> Context:
78 return self._context
79
80 @context.setter
81 def context(self, context: Context) -> None:
82 self._context = context
83
84 @abstractmethod
85 def handle1(self) -> None:
86 pass
87
88 @abstractmethod
89 def handle2(self) -> None:
90 pass
91
92
93"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected