Content deleted Content added
→Python: added python language tag |
→Python: cleaner source code, matches other examples in is_satisfied_by |
||
Line 230:
from abc import abstractmethod
from dataclasses import dataclass
from typing import Any
class BaseSpecification:
@abstractmethod
def is_satisfied_by(self, candidate: Any) -> bool:
raise NotImplementedError()
def
return AndSpecification(self, other)
def
return OrSpecification(self, other)
def
return NotSpecification(self)
Line 252 ⟶ 253:
second: BaseSpecification
def is_satisfied_by(self, candidate: Any) -> bool:
return self.first.is_satisfied_by(candidate) and self.second.is_satisfied_by(candidate)
Line 261 ⟶ 262:
second: BaseSpecification
def is_satisfied_by(self, candidate: Any) -> bool:
return self.first.is_satisfied_by(candidate) or self.second.is_satisfied_by(candidate)
Line 269 ⟶ 270:
subject: BaseSpecification
def is_satisfied_by(self, candidate: Any) -> bool:
return not self.subject.is_satisfied_by(candidate)
</source>
|