Skip to content

Commit 60b63dd

Browse files
committed
refactor: compare live locations types
1 parent 485a823 commit 60b63dd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/main/kotlin/spp/protocol/instrument/location/LiveLocation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface LiveLocation {
2626
val service: Service?
2727
val probeId: String?
2828

29-
fun isSameLocation(other: LiveLocation): Boolean
29+
fun isSameLocation(location: LiveLocation): Boolean
3030
fun toJson(): JsonObject
3131

3232
companion object {

src/main/kotlin/spp/protocol/instrument/location/LiveSourceLocation.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ data class LiveSourceLocation @JvmOverloads constructor(
5555
scope = json.getString("scope")?.let { LocationScope.valueOf(it) } ?: LocationScope.LINE
5656
)
5757

58-
override fun isSameLocation(other: LiveLocation): Boolean {
59-
if (other !is LiveSourceLocation) return false
60-
if (source != other.source) return false
61-
if (line != other.line && line != -1 && other.line != -1) return false //-1 is wildcard
62-
if (service != null && (other.service == null || !service.isSameLocation(other.service!!))) return false
63-
if (probeId != null && probeId != other.probeId) return false
58+
override fun isSameLocation(location: LiveLocation): Boolean {
59+
if (location !is LiveSourceLocation) return false
60+
if (source != location.source) return false
61+
if (line != location.line && line != -1 && location.line != -1) return false //-1 is wildcard
62+
if (service != null && (location.service == null || !service.isSameLocation(location.service!!))) return false
63+
if (probeId != null && probeId != location.probeId) return false
6464
return true
6565
}
6666

src/main/kotlin/spp/protocol/platform/general/Service.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ data class Service(
8989
/**
9090
* Ensures all non-null fields are equal.
9191
*/
92-
override fun isSameLocation(other: LiveLocation): Boolean {
93-
if (other !is Service) return false //todo: support other types
92+
override fun isSameLocation(location: LiveLocation): Boolean {
93+
val other = location.service ?: return false
9494
if (name != other.name) return false
9595
if (group != null && group != other.group) return false
9696
if (shortName != null && shortName != other.shortName) return false

0 commit comments

Comments
 (0)