| Total Complexity | 4 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | """ |
||
| 2 | Kerapu |
||
| 3 | """ |
||
| 4 | 1 | from kerapu.lbz.Subtraject import Subtraject |
|
| 5 | |||
| 6 | |||
| 7 | 1 | class AttribuutGroep: |
|
| 8 | """ |
||
| 9 | Klasse voor attribuutgroep. |
||
| 10 | """ |
||
| 11 | |||
| 12 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 13 | 1 | def __init__(self, |
|
| 14 | attribute_groep_id: int, |
||
| 15 | aantal_voorwaarden_voor_true: int, |
||
| 16 | koppelingen: list): |
||
| 17 | """ |
||
| 18 | Object constructor. |
||
| 19 | |||
| 20 | :param int attribute_groep_id: Het ID van deze attribuutgroep. |
||
| 21 | :param int aantal_voorwaarden_voor_true: Het minimale aantal voorwaarden waaraan moet worden voldaan. |
||
| 22 | :param list[kerapu.boom.attribuut_groep_koppeling.AttribuutGroepKoppeling.AttribuutGroepKoppeling] koppelingen: |
||
| 23 | De attribuutgroepkoppelingen. |
||
| 24 | """ |
||
| 25 | 1 | self._attribute_groep_id = attribute_groep_id |
|
| 26 | """ |
||
| 27 | Het ID van deze attribuutgroep. |
||
| 28 | |||
| 29 | :type: int |
||
| 30 | """ |
||
| 31 | |||
| 32 | 1 | self._aantal_voorwaarden_voor_true = aantal_voorwaarden_voor_true |
|
| 33 | """ |
||
| 34 | Het minimale aantal voorwaarden waaraan moet worden voldaan om deze attribuutgroep te laten vuren. |
||
| 35 | |||
| 36 | :type: int |
||
| 37 | """ |
||
| 38 | |||
| 39 | 1 | self._koppelingen = koppelingen |
|
| 40 | 1 | """ |
|
| 41 | De attribuutgroepkoppelingen. |
||
| 42 | |||
| 43 | :type: list[kerapu.boom.attribuut_groep_koppeling..AttribuutGroepKoppeling.AttribuutGroepKoppeling] |
||
| 44 | """ |
||
| 45 | |||
| 46 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 47 | 1 | def test(self, subtraject: Subtraject) -> bool: |
|
| 48 | """ |
||
| 49 | Test of een subtraject voldoet aan de voorwaarden van deze attribuutgroep. |
||
| 50 | |||
| 51 | :param Subtraject subtraject: Het subtraject. |
||
| 52 | |||
| 53 | :rtype: bool |
||
| 54 | """ |
||
| 55 | 1 | aantal = 0 |
|
| 56 | 1 | for koppeling in self._koppelingen: |
|
| 57 | 1 | if koppeling.test(subtraject): |
|
| 58 | 1 | aantal += 1 |
|
| 59 | |||
| 60 | 1 | return aantal >= self._aantal_voorwaarden_voor_true |
|
| 61 | |||
| 63 |