Skip to content

Commit 883a80a

Browse files
committed
chore(spdx-utils): Remove superfluous case distinctions for equals()
The `is SpdxExpression` case covers `SpdxCompoundExpression`s and `SpdxSingleLicenseExpression`s. As `SpdxCompoundExpressions` have at least 2 children, decomposition can never result in just a single element. This leaves `SpdxSingleLicenseExpression` to handle, but these can only ever by equal if they are of the same sub-type, which is already covered by the first case distinction. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 7d47932 commit 883a80a

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

utils/spdx/src/main/kotlin/SpdxExpression.kt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,6 @@ class SpdxLicenseWithExceptionExpression(
525525
override fun equals(other: Any?) =
526526
when (other) {
527527
is SpdxLicenseWithExceptionExpression -> license == other.license && exception == other.exception
528-
529-
is SpdxExpression -> {
530-
val decomposed = other.decompose()
531-
decomposed.singleOrNull()?.let {
532-
it is SpdxLicenseWithExceptionExpression && it.license == license && it.exception == exception
533-
} == true
534-
}
535-
536528
else -> false
537529
}
538530

@@ -590,14 +582,6 @@ class SpdxLicenseIdExpression(
590582
override fun equals(other: Any?) =
591583
when (other) {
592584
is SpdxLicenseIdExpression -> id == other.id && orLaterVersion == other.orLaterVersion
593-
594-
is SpdxExpression -> {
595-
val decomposed = other.decompose()
596-
decomposed.singleOrNull()?.let {
597-
it is SpdxLicenseIdExpression && it.id == id && it.orLaterVersion == orLaterVersion
598-
} == true
599-
}
600-
601585
else -> false
602586
}
603587

@@ -639,12 +623,6 @@ data class SpdxLicenseReferenceExpression(
639623
override fun equals(other: Any?) =
640624
when (other) {
641625
is SpdxLicenseReferenceExpression -> id == other.id
642-
643-
is SpdxExpression -> {
644-
val decomposed = other.decompose()
645-
decomposed.singleOrNull()?.let { it is SpdxLicenseReferenceExpression && it.id == id } == true
646-
}
647-
648626
else -> false
649627
}
650628

0 commit comments

Comments
 (0)