Skip to content

Commit

Permalink
Refactor _is_of_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
zrgt committed Aug 19, 2024
1 parent a05ed0a commit e1819e4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions basyx/aas/adapter/json/json_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_ts(dct: Dict[str, object], key: str, type_: Type[T]) -> T:
return val


def _is_of_type(object_: object, type_: Type, context: str, failsafe: bool) -> bool:
def _validate_type(object_: object, type_: Type, context: str, failsafe: bool) -> bool:
"""
Helper function to check type of an embedded object.
Expand Down Expand Up @@ -541,7 +541,7 @@ def _construct_entity(cls, dct: Dict[str, object], object_class=model.Entity) ->
cls._amend_abstract_attributes(ret, dct)
if not cls.stripped and 'statements' in dct:
for element in _get_ts(dct, "statements", list):
if _is_of_type(element, model.SubmodelElement, str(ret), cls.failsafe):
if _validate_type(element, model.SubmodelElement, str(ret), cls.failsafe):
ret.statement.add(element)
return ret

Expand Down Expand Up @@ -578,7 +578,7 @@ def _construct_submodel(cls, dct: Dict[str, object], object_class=model.Submodel
cls._amend_abstract_attributes(ret, dct)
if not cls.stripped and 'submodelElements' in dct:
for element in _get_ts(dct, "submodelElements", list):
if _is_of_type(element, model.SubmodelElement, str(ret), cls.failsafe):
if _validate_type(element, model.SubmodelElement, str(ret), cls.failsafe):
ret.submodel_element.add(element)
return ret

Expand Down Expand Up @@ -657,7 +657,7 @@ def _construct_annotated_relationship_element(
cls._amend_abstract_attributes(ret, dct)
if not cls.stripped and 'annotations' in dct:
for element in _get_ts(dct, 'annotations', list):
if _is_of_type(element, model.DataElement, str(ret), cls.failsafe):
if _validate_type(element, model.DataElement, str(ret), cls.failsafe):
ret.annotation.add(element)
return ret

Expand All @@ -669,7 +669,7 @@ def _construct_submodel_element_collection(cls, dct: Dict[str, object],
cls._amend_abstract_attributes(ret, dct)
if not cls.stripped and 'value' in dct:
for element in _get_ts(dct, "value", list):
if _is_of_type(element, model.SubmodelElement, str(ret), cls.failsafe):
if _validate_type(element, model.SubmodelElement, str(ret), cls.failsafe):
ret.value.add(element)
return ret

Expand All @@ -694,7 +694,7 @@ def _construct_submodel_element_list(cls, dct: Dict[str, object], object_class=m
cls._amend_abstract_attributes(ret, dct)
if not cls.stripped and 'value' in dct:
for element in _get_ts(dct, 'value', list):
if _is_of_type(element, type_value_list_element, str(ret), cls.failsafe):
if _validate_type(element, type_value_list_element, str(ret), cls.failsafe):
ret.value.add(element)
return ret

Expand Down

0 comments on commit e1819e4

Please sign in to comment.