@@ -107,11 +107,12 @@ sealed class SpdxExpression {
107
107
}
108
108
109
109
/* *
110
- * Normalize all license IDs using [SpdxSimpleLicenseMapping]. If [mapDeprecated] is `true`, also deprecated IDs are
111
- * mapped to their current counterparts. The result of this function is not guaranteed to contain only valid IDs.
112
- * Use [validate] or [isValid] to check the returned [SpdxExpression] for validity afterwards.
110
+ * Normalize all license IDs using [SpdxSimpleLicenseMapping]. If [mapDeprecated] is `true`, this involves mapping
111
+ * deprecated IDs to their current counterparts. If [mapSimple] is `true`, also commonly known abbreviations or
112
+ * aliases are mapped. The result of this function is not guaranteed to contain only valid IDs. Use [validate] or
113
+ * [isValid] to check the returned [SpdxExpression] for validity afterwards.
113
114
*/
114
- abstract fun normalize (mapDeprecated : Boolean = true): SpdxExpression
115
+ abstract fun normalize (mapDeprecated : Boolean = true, mapSimple : Boolean = true ): SpdxExpression
115
116
116
117
/* *
117
118
* Return a simplified expression that has e.g. redundancies removed.
@@ -246,8 +247,8 @@ class SpdxCompoundExpression(
246
247
247
248
override fun decompose (): Set <SpdxSingleLicenseExpression > = children.flatMapTo(mutableSetOf ()) { it.decompose() }
248
249
249
- override fun normalize (mapDeprecated : Boolean ) =
250
- SpdxCompoundExpression (operator , children.map { it.normalize(mapDeprecated) })
250
+ override fun normalize (mapDeprecated : Boolean , mapSimple : Boolean ) =
251
+ SpdxCompoundExpression (operator , children.map { it.normalize(mapDeprecated, mapSimple ) })
251
252
252
253
private fun flatten (): SpdxExpression {
253
254
val flattenedChildren = children.flatMapTo(mutableSetOf ()) { child ->
@@ -460,10 +461,10 @@ class SpdxLicenseWithExceptionExpression(
460
461
461
462
override fun exception () = exception
462
463
463
- override fun normalize (mapDeprecated : Boolean ) =
464
+ override fun normalize (mapDeprecated : Boolean , mapSimple : Boolean ) =
464
465
// Manually cast to SpdxSingleLicenseExpression as the type resolver does not recognize that in all subclasses
465
466
// of SpdxSimpleExpression normalize() returns an SpdxSingleLicenseExpression.
466
- when (val normalizedLicense = license.normalize(mapDeprecated) as SpdxSingleLicenseExpression ) {
467
+ when (val normalizedLicense = license.normalize(mapDeprecated, mapSimple ) as SpdxSingleLicenseExpression ) {
467
468
is SpdxSimpleExpression -> SpdxLicenseWithExceptionExpression (normalizedLicense, exception)
468
469
469
470
// This case happens if a deprecated license identifier that contains an exception is used together with
@@ -554,7 +555,8 @@ class SpdxLicenseIdExpression(
554
555
555
556
override fun exception (): String? = null
556
557
557
- override fun normalize (mapDeprecated : Boolean ) = SpdxSimpleLicenseMapping .map(toString(), mapDeprecated) ? : this
558
+ override fun normalize (mapDeprecated : Boolean , mapSimple : Boolean ) =
559
+ SpdxSimpleLicenseMapping .map(toString(), mapDeprecated, mapSimple) ? : this
558
560
559
561
override fun validate (strictness : Strictness ) {
560
562
val isValid = SpdxConstants .isNotPresent(id) || when (strictness) {
@@ -607,7 +609,7 @@ data class SpdxLicenseReferenceExpression(
607
609
608
610
override fun exception (): String? = null
609
611
610
- override fun normalize (mapDeprecated : Boolean ) = this
612
+ override fun normalize (mapDeprecated : Boolean , mapSimple : Boolean ) = this
611
613
612
614
override fun validate (strictness : Strictness ) {
613
615
val isLicenseRef = id.startsWith(LICENSE_REF_PREFIX )
0 commit comments