1818
1919from typing import TYPE_CHECKING , Any , Optional
2020
21- import py_serializable as serializable
22-
2321from ..exception .serialization import CycloneDxDeserializationException , SerializationOfUnexpectedValueException
2422
2523if TYPE_CHECKING : # pragma: no cover
2624 from typing import TypeVar
27-
2825 _T_BR = TypeVar ('_T_BR' , bound = 'BomRef' )
2926
3027
31- @serializable .serializable_class (ignore_unknown_during_deserialization = True )
32- class BomRef (serializable .helpers .BaseHelper ):
28+ class BomRef :
3329 """
3430 An identifier that can be used to reference objects elsewhere in the BOM.
3531
@@ -40,11 +36,10 @@ class BomRef(serializable.helpers.BaseHelper):
4036 """
4137
4238 def __init__ (self , value : Optional [str ] = None ) -> None :
43- self .value = value
39+ # empty strings become `None`
40+ self ._value = value or None
4441
4542 @property
46- @serializable .json_name ('.' )
47- @serializable .xml_name ('.' )
4843 def value (self ) -> Optional [str ]:
4944 return self ._value
5045
@@ -80,8 +75,6 @@ def __str__(self) -> str:
8075 def __bool__ (self ) -> bool :
8176 return self ._value is not None
8277
83- # region impl BaseHelper
84-
8578 @classmethod
8679 def serialize (cls , o : Any ) -> Optional [str ]:
8780 if isinstance (o , cls ):
@@ -97,5 +90,3 @@ def deserialize(cls: 'type[_T_BR]', o: Any) -> '_T_BR':
9790 raise CycloneDxDeserializationException (
9891 f'BomRef string supplied does not parse: { o !r} '
9992 ) from err
100-
101- # endregion impl BaseHelper
0 commit comments