3232from .._internal .compare import ComparableTuple as _ComparableTuple
3333from ..exception .model import MutuallyExclusivePropertiesException
3434from ..exception .serialization import CycloneDxDeserializationException
35- from ..schema .schema import SchemaVersion1Dot6
36- from . import AttachedText , XsUri
35+ from ..schema .schema import SchemaVersion1Dot6 , SchemaVersion1Dot5
36+ from . import AttachedText , XsUri , BomRef
37+ from .._internal .bom_ref import bom_ref_from_str as _bom_ref_from_str
3738
3839
3940@serializable .serializable_enum
@@ -75,6 +76,7 @@ class DisjunctiveLicense:
7576
7677 def __init__ (
7778 self , * ,
79+ bom_ref : Optional [Union [str , BomRef ]] = None ,
7880 id : Optional [str ] = None , name : Optional [str ] = None ,
7981 text : Optional [AttachedText ] = None , url : Optional [XsUri ] = None ,
8082 acknowledgement : Optional [LicenseAcknowledgement ] = None ,
@@ -86,12 +88,31 @@ def __init__(
8688 'Both `id` and `name` have been supplied - `name` will be ignored!' ,
8789 category = RuntimeWarning , stacklevel = 1
8890 )
91+ self ._bom_ref = _bom_ref_from_str (bom_ref )
8992 self ._id = id
9093 self ._name = name if not id else None
9194 self ._text = text
9295 self ._url = url
9396 self ._acknowledgement = acknowledgement
9497
98+ @property
99+ @serializable .view (SchemaVersion1Dot5 )
100+ @serializable .view (SchemaVersion1Dot6 )
101+ @serializable .type_mapping (BomRef )
102+ @serializable .xml_attribute ()
103+ @serializable .xml_name ('bom-ref' )
104+ @serializable .json_name ('bom-ref' )
105+ def bom_ref (self ) -> BomRef :
106+ """
107+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
108+ unique within the BOM.
109+
110+ Returns:
111+ `BomRef`
112+ """
113+ return self ._bom_ref
114+
115+
95116 @property
96117 @serializable .xml_sequence (1 )
97118 def id (self ) -> Optional [str ]:
@@ -186,16 +207,6 @@ def url(self, url: Optional[XsUri]) -> None:
186207 # def properties(self, ...) -> None:
187208 # ... # TODO since CDX1.5
188209
189- # @property
190- # @serializable.json_name('bom-ref')
191- # @serializable.type_mapping(BomRefHelper)
192- # @serializable.view(SchemaVersion1Dot5)
193- # @serializable.view(SchemaVersion1Dot6)
194- # @serializable.xml_attribute()
195- # @serializable.xml_name('bom-ref')
196- # def bom_ref(self) -> BomRef:
197- # ... # TODO since CDX1.5
198-
199210 @property
200211 @serializable .view (SchemaVersion1Dot6 )
201212 @serializable .xml_attribute ()
@@ -227,6 +238,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
227238 self ._id , self ._name ,
228239 self ._url ,
229240 self ._text ,
241+ self ._bom_ref ,
230242 ))
231243
232244 def __eq__ (self , other : object ) -> bool :
@@ -264,11 +276,31 @@ class LicenseExpression:
264276
265277 def __init__ (
266278 self , value : str , * ,
279+ bom_ref : Optional [Union [str , BomRef ]] = None ,
267280 acknowledgement : Optional [LicenseAcknowledgement ] = None ,
268281 ) -> None :
282+ self ._bom_ref = _bom_ref_from_str (bom_ref )
269283 self ._value = value
270284 self ._acknowledgement = acknowledgement
271285
286+ @property
287+ @serializable .view (SchemaVersion1Dot5 )
288+ @serializable .view (SchemaVersion1Dot6 )
289+ @serializable .type_mapping (BomRef )
290+ @serializable .xml_attribute ()
291+ @serializable .xml_name ('bom-ref' )
292+ @serializable .json_name ('bom-ref' )
293+ def bom_ref (self ) -> BomRef :
294+ """
295+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
296+ unique within the BOM.
297+
298+ Returns:
299+ `BomRef`
300+ """
301+ return self ._bom_ref
302+
303+
272304 @property
273305 @serializable .xml_name ('.' )
274306 @serializable .xml_string (serializable .XmlStringSerializationType .NORMALIZED_STRING )
@@ -286,16 +318,6 @@ def value(self) -> str:
286318 def value (self , value : str ) -> None :
287319 self ._value = value
288320
289- # @property
290- # @serializable.json_name('bom-ref')
291- # @serializable.type_mapping(BomRefHelper)
292- # @serializable.view(SchemaVersion1Dot5)
293- # @serializable.view(SchemaVersion1Dot6)
294- # @serializable.xml_attribute()
295- # @serializable.xml_name('bom-ref')
296- # def bom_ref(self) -> BomRef:
297- # ... # TODO since CDX1.5
298-
299321 @property
300322 @serializable .view (SchemaVersion1Dot6 )
301323 @serializable .xml_attribute ()
@@ -325,6 +347,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
325347 return _ComparableTuple ((
326348 self ._acknowledgement ,
327349 self ._value ,
350+ self .bom_ref ,
328351 ))
329352
330353 def __hash__ (self ) -> int :
0 commit comments