|
1 | 1 | # Copyright (c) 2025 the Eclipse BaSyx Authors |
2 | | -# |
| 2 | +# |
3 | 3 | # This program and the accompanying materials are made available under the terms of the MIT License, available in |
4 | 4 | # the LICENSE file of this project. |
5 | 5 | # |
@@ -614,9 +614,9 @@ class Referable(HasExtension, metaclass=abc.ABCMeta): |
614 | 614 | def __init__(self): |
615 | 615 | super().__init__() |
616 | 616 | self._id_short: Optional[NameType] = None |
617 | | - self.display_name: Optional[MultiLanguageNameType] = dict() |
| 617 | + self._display_name: Optional[MultiLanguageNameType] = None |
618 | 618 | self._category: Optional[NameType] = None |
619 | | - self.description: Optional[MultiLanguageTextType] = dict() |
| 619 | + self._description: Optional[MultiLanguageTextType] = None |
620 | 620 | # We use a Python reference to the parent Namespace instead of a Reference Object, as specified. This allows |
621 | 621 | # simpler and faster navigation/checks and it has no effect in the serialized data formats anyway. |
622 | 622 | self.parent: Optional[UniqueIdShortNamespace] = None |
@@ -708,7 +708,7 @@ def _set_category(self, category: Optional[NameType]): |
708 | 708 | self._category = category |
709 | 709 |
|
710 | 710 | def _get_category(self) -> Optional[NameType]: |
711 | | - return self._category |
| 711 | + return self._category |
712 | 712 |
|
713 | 713 | @classmethod |
714 | 714 | def parse_id_short_path(cls, id_short_path: str) -> List[str]: |
@@ -826,6 +826,64 @@ def _set_id_short(self, id_short: Optional[NameType]): |
826 | 826 | set_.add(self) |
827 | 827 | # Redundant to the line above. However, this way, we make sure that we really update the _id_short |
828 | 828 | self._id_short = id_short |
| 829 | + |
| 830 | + |
| 831 | + def _check_multiLanguageNameType(self, value): |
| 832 | + """ |
| 833 | + Check that the given type is either None or of type MultiLanguageNameType |
| 834 | +
|
| 835 | + :param value: The display name to check |
| 836 | + :raises TypeError: If the type is not :datatype:`MultiLanguageNameType` or `None` |
| 837 | + """ |
| 838 | + |
| 839 | + if value is not None and not isinstance(value, MultiLanguageNameType): |
| 840 | + raise TypeError( |
| 841 | + f"display_name must be of type MultiLanguageNameType, but got {type(value)}" |
| 842 | + ) |
| 843 | + |
| 844 | + def _get_display_name(self) -> Optional[MultiLanguageNameType]: |
| 845 | + return self._display_name |
| 846 | + |
| 847 | + def _set_display_name(self, display_name: Optional[MultiLanguageNameType]): |
| 848 | + """ |
| 849 | + Check the input type and then set the display_name |
| 850 | +
|
| 851 | + :param display_name: MultiLanguageNameType for the display name of the element |
| 852 | + :raises TypeError: if the type is not correct |
| 853 | + """ |
| 854 | + self._check_multiLanguageNameType(display_name) |
| 855 | + self._display_name = display_name |
| 856 | + |
| 857 | + display_name = property(_get_display_name, _set_display_name) |
| 858 | + |
| 859 | + |
| 860 | + def _check_MultiLanguageTextType(self, value): |
| 861 | + """ |
| 862 | + Check that the given type is either None or of type MultiLanguageTextType |
| 863 | +
|
| 864 | + :param value: The description to check |
| 865 | + :raises TypeError: if the type is not :datatype:`MultiLanguageTextType` or `None` |
| 866 | + """ |
| 867 | + |
| 868 | + if value is not None and not isinstance(value, MultiLanguageTextType): |
| 869 | + raise TypeError( |
| 870 | + f"description must be of type MultiLanguageTextType, but got {type(value)}" |
| 871 | + ) |
| 872 | + |
| 873 | + def _get_description(self) -> Optional[MultiLanguageTextType]: |
| 874 | + return self._description |
| 875 | + |
| 876 | + def _set_description(self, description: Optional[MultiLanguageTextType]): |
| 877 | + """ |
| 878 | + Check the input type and then set the description |
| 879 | +
|
| 880 | + :param description: MultiLanguageTextType for the description of the element |
| 881 | + :raises TypeError: if the type is not correct |
| 882 | + """ |
| 883 | + self._check_MultiLanguageTextType(description) |
| 884 | + self._description = description |
| 885 | + |
| 886 | + description = property(_get_description, _set_description) |
829 | 887 |
|
830 | 888 | def update_from(self, other: "Referable"): |
831 | 889 | """ |
|
0 commit comments